]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/notes.js.erb
Disable "Add Note" button when there is no text
[rails.git] / app / assets / javascripts / index / notes.js.erb
index 3c6703bfa7824e3db945708a338fb1dca0541091..9f8eb2f545387608591bf39041fc12deaf55ae99 100644 (file)
@@ -225,6 +225,16 @@ $(document).ready(function () {
 
     var popupContent = $(JST["templates/notes/new"]({ create_url: $(e.target).attr("href") }));
 
 
     var popupContent = $(JST["templates/notes/new"]({ create_url: $(e.target).attr("href") }));
 
+    popupContent.find("textarea").on("input", function (e) {
+      var form = e.target.form;
+
+      if ($(e.target).val() == "") {
+        $(form.add).prop("disabled", true);
+      } else {
+        $(form.add).prop("disabled", false);
+      }
+    });
+
     popupContent.find("input[type=submit]").on("click", function (e) {
       e.preventDefault();
       createNote(marker, e.target.form, $(e.target).data("url"));
     popupContent.find("input[type=submit]").on("click", function (e) {
       e.preventDefault();
       createNote(marker, e.target.form, $(e.target).data("url"));