Permalink
Browse files

add modal for when requests fail

  • Loading branch information...
1 parent 5da6409 commit 72f0297e0a574dee27f702e7dc637e9d4aa63474 @lukebaker lukebaker committed Sep 30, 2013
Showing with 22 additions and 10 deletions.
  1. +10 −10 app/views/earls/_vote_box_js.html.erb
  2. +12 −0 app/views/earls/show.html.haml
View
20 app/views/earls/_vote_box_js.html.erb
@@ -83,7 +83,9 @@
box.find('.idea-success').hide(300);
}, 5 * 1000);
- }, "json");
+ }, "json").fail(function() {
+ $('#request_error').modal('show');
+ });
});
@@ -165,13 +167,7 @@
error: function(request,error) {
winningLink.addClass('btn-primary').removeClass('btn-success').removeClass('disabled');
losingLink.addClass('btn-primary').removeClass('disabled');
- if (error == "timeout") {
- $('.tellmearea').html('<%= t('vote.vote_timeout_error')%>').effect("highlight", {color: '#ff0000'}, 1500);
- }
- else {
- $('.tellmearea').html("<%= t('vote.vote_other_error') %>").effect("highlight", {color: '#ff0000'}, 1500);
- }
-
+ $('#request_error').modal('show');
loadedTime = new Date(); //reset loaded time
},
success: function(data){
@@ -225,7 +221,9 @@
$('#appearance_lookup').val(data["appearance_lookup"]);
//clear the radio buttons somehow?
loadedTime = new Date() //reset loaded time
- },"json");
+ },"json").fail(function() {
+ $('#request_error').modal('show');
+ });;
});
@@ -285,5 +283,7 @@
$('#item_count').html(decrement(current_item_count));
loadedTime = new Date() //reset loaded time
}
- }, "json");
+ }, "json").fail(function() {
+ $('#request_error').modal('show');
+ });
});
View
12 app/views/earls/show.html.haml
@@ -50,6 +50,18 @@
= render :partial => 'items/form'
.tellmearea
+#request_error.hide.modal.fade
+ .modal-header
+ %button.close{:"data-dismiss" => 'modal'} x
+ %h2 Error Processing Your Request
+ .modal-body
+ %p
+ There was a problem processing your request. Sometimes this happens when your browser cookies are deleted. When you close this message, the page will reload, and you can try again.
+-content_for :view_javascript do
+ :plain
+ $('#request_error').on('hide', function() {
+ window.location.reload(false);
+ });
#cant_decide_options.hide.modal.fade
.modal-header
%button.close{:"data-dismiss" => 'modal'} x

0 comments on commit 72f0297

Please sign in to comment.