Disable "Add Note" button when there is no text
authorTom Hughes <tom@compton.nu>
Sun, 3 Feb 2013 18:03:25 +0000 (18:03 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 3 Feb 2013 18:03:25 +0000 (18:03 +0000)
app/assets/javascripts/index/notes.js.erb
app/assets/javascripts/templates/notes/new.jst.ejs

index 3c6703b..9f8eb2f 100644 (file)
@@ -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"));
index 0b074ec..2f12227 100644 (file)
@@ -6,7 +6,7 @@
     <textarea class="comment" name="text" cols="40" rows="10"></textarea>
     <br/>
     <div class="buttons">
-      <input type="submit" name="add" value="<%- I18n.t('javascripts.notes.new.add') %>" data-url="<%- create_url %>">
+      <input type="submit" name="add" value="<%- I18n.t('javascripts.notes.new.add') %>" data-url="<%- create_url %>" disabled="1">
     </div>
   </form>
 </div>