From e067443756b1d77ec780523067224a9070916cfe Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Mon, 16 Apr 2018 09:33:53 +1000 Subject: [PATCH] Update to latest FormSaver, triggering change events when form fields are updated --- apps/map/static/map/plugins/FormSaver.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/map/static/map/plugins/FormSaver.js b/apps/map/static/map/plugins/FormSaver.js index 27814a0..7d419f0 100644 --- a/apps/map/static/map/plugins/FormSaver.js +++ b/apps/map/static/map/plugins/FormSaver.js @@ -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;