Commit 2daa6161fd08e18bdf7f1ad0f30a83a58226543e

Authored by gitlabhq
1 parent 74a89d9e

prevent double note submit

app/views/notes/_form.html.haml
@@ -25,4 +25,4 @@ @@ -25,4 +25,4 @@
25 25
26 .clear 26 .clear
27 %br 27 %br
28 - = f.submit 'Add note', :class => "lbutton vm" 28 + = f.submit 'Add note', :class => "lbutton vm", :id => "submit_note"
app/views/notes/_notes.html.haml
@@ -9,6 +9,15 @@ @@ -9,6 +9,15 @@
9 $('.delete-note').live('ajax:success', function() { 9 $('.delete-note').live('ajax:success', function() {
10 $(this).closest('li').fadeOut(); }); 10 $(this).closest('li').fadeOut(); });
11 11
  12 + $("#new_note").live("ajax:before", function(){
  13 + $("#submit_note").attr("disabled", "disabled");
  14 + })
  15 +
  16 + $("#new_note").live("ajax:complete", function(){
  17 + $("#submit_note").removeAttr("disabled");
  18 + })
  19 +
  20 +
12 - if ["issues", "projects"].include?(controller.controller_name) 21 - if ["issues", "projects"].include?(controller.controller_name)
13 :javascript 22 :javascript
14 $(function(){ 23 $(function(){
app/views/notes/create.js.haml
@@ -6,3 +6,6 @@ @@ -6,3 +6,6 @@
6 - else 6 - else
7 :plain 7 :plain
8 $("#new_note").replaceWith("#{escape_javascript(render('form'))}"); 8 $("#new_note").replaceWith("#{escape_javascript(render('form'))}");
  9 +
  10 +:plain
  11 + $("#submit_note").removeAttr("disabled");