3112: report issue success event handling working in 404 error page.
[arvados.git] / apps / workbench / app / assets / javascripts / report_issue.js
index 362a9a1b033e11cca148568b96962aab54dec1ba..a05cba59837b5ead95ca0ccd5aeea2a552d56792 100644 (file)
@@ -1,36 +1,31 @@
-// ajax handling for report-issue function
 $(document).
-  on('ajax:send', function() {
-    var $sendButton = $('#report-issue-submit');
-    if ($sendButton) {
-      $sendButton.html('Sending...');
-      $sendButton.attr('disabled',true);
-    }
+  on('click', "#report-issue-submit", function(e){
+    $(this).html('Sending');
+    $(this).attr('disabled', true);
     var $cancelButton = $('#report-issue-cancel');
     if ($cancelButton) {
       $cancelButton.html('Close');
     }
     $('div').remove('.modal-footer-status');
-  }).
-  on('ajax:success', function() {
-    var $sendButton = $('#report-issue-submit');
-    if ($sendButton  && $sendButton.prop('disabled')) {
-      $sendButton.html('Report sent');
-      $('div').remove('.modal-footer-status');
-      $('.modal-footer').append('<div class="modal-footer-status alert alert-success"><div><p align="left">Thanks for reporting this issue!</p></div></div>');
-    }
-  }).
-  on('ajax:failure', function() {
-    var $sendButton = $('#report-issue-submit');
-    if ($sendButton && $sendButton.prop('disabled')) {
-      $('div').remove('.modal-footer-status');
-      $('.modal-footer').append('<div class="modal-footer-status alert alert-danger"></br><p align="left">We are sorry. We could not submit your report! We really want this to work, though -- please try again.</p></div>');
-      $sendButton.html('Report a problem');
-      $sendButton.attr('disabled',false);
-    }
-    var $cancelButton = $('#report-issue-cancel');
-    if ($cancelButton) {
-      var text = document.getElementById('report-issue-cancel').firstChild;
-      $cancelButton.html('Cancel');
-    }
+
+    $.ajax('/').
+      success(function(data, status, jqxhr) {
+        var $sendButton = $('#report-issue-submit');
+        $sendButton.html('Report sent');
+        $('div').remove('.modal-footer-status');
+        $('.modal-footer').append('<div class="modal-footer-status alert alert-success"><div><p align="left">Thanks for reporting this issue!</p></div></div>');
+      }).
+      fail(function(jqxhr, status, error) {
+        var $sendButton = $('#report-issue-submit');
+        if ($sendButton && $sendButton.prop('disabled')) {
+        $('div').remove('.modal-footer-status');
+        $('.modal-footer').append('<div class="modal-footer-status alert alert-danger"></br><p align="left">We are sorry. We could not submit your report! We really want this to work, though -- please try again.</p></div>');
+        $sendButton.html('Send problem report');
+        $sendButton.attr('disabled',false);
+      }
+        var $cancelButton = $('#report-issue-cancel');
+        var text = document.getElementById('report-issue-cancel').firstChild;
+        $cancelButton.html('Cancel');
+      });
+
   });