add unbeforeunload in editor if currently editing something
This commit is contained in:
parent
0af1599eb9
commit
4a8add1395
2 changed files with 7 additions and 1 deletions
|
@ -24,6 +24,7 @@ editor = {
|
||||||
editor.map.on('click', function () {
|
editor.map.on('click', function () {
|
||||||
editor.map.doubleClickZoom.enable();
|
editor.map.doubleClickZoom.enable();
|
||||||
});
|
});
|
||||||
|
window.onbeforeunload = editor._onbeforeunload;
|
||||||
|
|
||||||
L.control.scale({imperial: false}).addTo(editor.map);
|
L.control.scale({imperial: false}).addTo(editor.map);
|
||||||
|
|
||||||
|
@ -46,6 +47,11 @@ editor = {
|
||||||
editor.map.setMaxBounds(bounds);
|
editor.map.setMaxBounds(bounds);
|
||||||
editor.map.fitBounds(bounds, {padding: [30, 50]});
|
editor.map.fitBounds(bounds, {padding: [30, 50]});
|
||||||
},
|
},
|
||||||
|
_onbeforeunload: function(e) {
|
||||||
|
if ($('#sidebar').find('[data-onbeforeunload]').length) {
|
||||||
|
e.returnValue = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// sources
|
// sources
|
||||||
sources: {},
|
sources: {},
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<h3>{% blocktrans %}Edit {{ model_title }}{% endblocktrans %}</h3>
|
<h3>{% blocktrans %}Edit {{ model_title }}{% endblocktrans %}</h3>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<form action="{{ path }}" method="post">
|
<form action="{{ path }}" method="post" data-onbeforeunload>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% bootstrap_form form %}
|
{% bootstrap_form form %}
|
||||||
{% buttons %}
|
{% buttons %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue