diff --git a/modules/backend/widgets/form/assets/js/october.form.js b/modules/backend/widgets/form/assets/js/october.form.js index f309896f9..67784ce11 100644 --- a/modules/backend/widgets/form/assets/js/october.form.js +++ b/modules/backend/widgets/form/assets/js/october.form.js @@ -13,6 +13,7 @@ this.options = options || {}; this.bindDependants() + this.bindCheckboxlist() this.toggleEmptyTabs() } @@ -20,6 +21,28 @@ refreshHandler: null } + /* + * Logic for checkboxlist + */ + FormWidget.prototype.bindCheckboxlist = function() { + + var checkAllBoxes = function($field, flag) { + $('input[type=checkbox]', $field) + .prop('checked', flag) + .first() + .trigger('change') + } + + this.$el.on('click', '[data-field-checkboxlist-all]', function() { + checkAllBoxes($(this).closest('.field-checkboxlist'), true) + }) + + this.$el.on('click', '[data-field-checkboxlist-none]', function() { + checkAllBoxes($(this).closest('.field-checkboxlist'), false) + }) + + } + /* * Bind dependant fields */ diff --git a/modules/backend/widgets/form/partials/_field_checkboxlist.htm b/modules/backend/widgets/form/partials/_field_checkboxlist.htm index fcfc479a1..9c2447214 100644 --- a/modules/backend/widgets/form/partials/_field_checkboxlist.htm +++ b/modules/backend/widgets/form/partials/_field_checkboxlist.htm @@ -40,12 +40,12 @@ : - , - + , + -
+