From ee88a3160e3d05410b4e6853eae7fa235848ff97 Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Mon, 16 Apr 2018 10:23:06 +1000 Subject: [PATCH] Get location field integrating with form saving/loading (#52) --- apps/map/templates/map/form.html | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/map/templates/map/form.html b/apps/map/templates/map/form.html index 7c91cc6..10cfd4d 100644 --- a/apps/map/templates/map/form.html +++ b/apps/map/templates/map/form.html @@ -106,7 +106,6 @@ // Add a help text control this._zoomHelpText = new ZoomHelpText().addTo(map) - console.log(this._zoomHelpText) // Only allow editing past a certain zoom level (see #56) // Remove the edit controls @@ -120,6 +119,19 @@ this.zoomLevelTooLow() } }) + + // Respond to underlying text field changing + const textarea = document.getElementById(this.options.fieldid) + textarea.addEventListener('change', evt => { + this.load() + }) + + const triggerChange = evt => { + document.getElementById('case-study-form').dispatchEvent(new Event('dirty')) + } + map.on(L.Draw.Event.CREATED, triggerChange) + map.on(L.Draw.Event.EDITED, triggerChange) + map.on(L.Draw.Event.DELETED, triggerChange) }, })