From: Tom Hughes Date: Sun, 3 Feb 2013 18:03:25 +0000 (+0000) Subject: Disable "Add Note" button when there is no text X-Git-Tag: live~5096^2~29 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/b97fe91bba29c942a3e5924dd7d81a940e7a1d3b Disable "Add Note" button when there is no text --- diff --git a/app/assets/javascripts/index/notes.js.erb b/app/assets/javascripts/index/notes.js.erb index 3c6703bfa..9f8eb2f54 100644 --- a/app/assets/javascripts/index/notes.js.erb +++ b/app/assets/javascripts/index/notes.js.erb @@ -225,6 +225,16 @@ $(document).ready(function () { 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")); diff --git a/app/assets/javascripts/templates/notes/new.jst.ejs b/app/assets/javascripts/templates/notes/new.jst.ejs index 0b074ec3b..2f12227fd 100644 --- a/app/assets/javascripts/templates/notes/new.jst.ejs +++ b/app/assets/javascripts/templates/notes/new.jst.ejs @@ -6,7 +6,7 @@
- +