- // Select the button reflecting the last-saved-state
- $('label.btn input[value=' +
- context.toggle_group.attr('data-persistent-state') +
- ']', context.toggle_group).
- button('toggle');
- if (jqxhr.responseJSON && jqxhr.responseJSON.errors) {
+ // Change to the last-saved-state
+ saved_state = context.toggle_group.attr('data-persistent-state');
+ $(context.button).
+ toggleClass('active', saved_state == 'persistent').
+ html(saved_state == 'persistent' ? 'Persistent' : 'Cache');
+
+ if (jqxhr.readyState == 0 || jqxhr.status == 0) {
+ // Request cancelled due to page reload.
+ // Displaying an alert would be rather annoying.
+ } else if (jqxhr.responseJSON && jqxhr.responseJSON.errors) {