]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/skins/default/templates/answer_edit.html
warning users that edits will be lost if they navigate away from the page.
[osqa.git] / forum / skins / default / templates / answer_edit.html
index 137b68413c7ca6ade8f3a9587cb93f426d90f0c4..66712ac526ceff97d8f8a5175dc24e3eb715642f 100644 (file)
             $('#id_revision').unbind().change(function(){
                 $("#select_revision").click();
             });
-            
-            
         });
+
+        function beforeUnload(e) {
+            if($("textarea#editor")[0].value != "") {
+               yourWorkWillBeLost(e);
+            }
+
+            return false;
+        }
+        window.addEventListener('beforeunload', beforeUnload, true);
         </script>
 {% endblock %}
         
@@ -66,7 +73,7 @@
             <div class="title-desc">
                 {{ form.summary.help_text }}
             </div>
-            <input type="submit" value="{% trans "Save edit" %}" class="submit" />
+            <input type="submit" value="{% trans "Save edit" %}" class="submit" onclick="window.removeEventListener('beforeunload', beforeUnload, true)" />
             <input type="button" value="{% trans "Cancel" %}" class="submit" onclick="history.back(-1);" />
         </form>
     </div>