Permalink
Browse files

BUGFIX: Update the batch action select state also on load (os7304)

This approach should cover more situations than the previous one. It
will owrk regardless of the initial state in the HTML (which can be
loaded from deferred cache).
  • Loading branch information...
1 parent b28a625 commit 905115b4dbdbccbbe146b3cbd73fe68d6997e611 @mateusz mateusz committed May 11, 2012
Showing with 18 additions and 6 deletions.
  1. +18 −6 admin/javascript/LeftAndMain.BatchActions.js
@@ -43,7 +43,7 @@
tree.bind('check_node.jstree', function(e, data) {
self.serializeFromTree();
});
-
+
$('.cms-tree-view-modes :input[name=view-mode]').bind('click', function(e) {
var val = $(e.target).val(), dropdown = self.find(':input[name=Action]');
if(val == 'multiselect') {
@@ -53,15 +53,27 @@
tree.removeClass('multiple');
}
- // Batch actions only make sense when multiselect is enabled
- if(val == 'multiselect') dropdown.removeAttr('disabled').change();
- else dropdown.attr('disabled', 'disabled').change();
+ self._updateStateFromViewMode();
});
-
+
+ self._updateStateFromViewMode();
+
this._super();
},
/**
+ * Updates the select box state according to the current view mode.
+ */
+ _updateStateFromViewMode: function() {
+ var viewMode = $('.cms-tree-view-modes :input[name=view-mode]:checked').val();
+ var dropdown = this.find(':input[name=Action]');
+
+ // Batch actions only make sense when multiselect is enabled.
+ if(viewMode == 'multiselect') dropdown.removeAttr('disabled').trigger("liszt:updated");
+ else dropdown.attr('disabled', true).trigger("liszt:updated");
+ },
+
+ /**
* Function: register
*
* Parameters:
@@ -350,4 +362,4 @@
});
});
-})(jQuery);
+})(jQuery);

0 comments on commit 905115b

Please sign in to comment.