Update to latest FormSaver, triggering change events when form fields are updated

This commit is contained in:
Anna Sidwell 2018-04-16 09:33:53 +10:00
parent 67fa6c6b74
commit e067443756

View File

@ -69,6 +69,11 @@ var FormSaver = function () {
return tag;
}
}
}, {
key: "triggerChangeEvent",
value: function triggerChangeEvent(element) {
element.dispatchEvent(new Event('change'));
}
}, {
key: "deserialise",
value: function deserialise(data) {
@ -123,6 +128,8 @@ var FormSaver = function () {
} else {
element.value = field.value;
}
this.triggerChangeEvent(element);
} else {
// We've got a list. This means we're radio or checkbox.
// Go over all the elements and select the right ones
@ -134,7 +141,11 @@ var FormSaver = function () {
for (var _iterator3 = element[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var input = _step3.value;
var oldVal = input.checked;
input.checked = field.value.includes(input.value);
if (oldVal !== input.checked) {
this.triggerChangeEvent(input);
}
}
} catch (err) {
_didIteratorError3 = true;