Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New event added for tree.checkboxes, to fix issue #403 #411

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/tree/js/tree.checkboxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ gj.tree.plugins.checkboxes = {
gj.tree.plugins.checkboxes.private.updateChildrenState($node, state);
gj.tree.plugins.checkboxes.private.updateParentState($node, state);
}
gj.tree.plugins.checkboxes.events.changed($tree, $node, record, $checkbox.state());
});
$expander.after($wrapper);
},
Expand Down Expand Up @@ -334,6 +335,25 @@ gj.tree.plugins.checkboxes = {
*/
checkboxChange: function ($tree, $node, record, state) {
return $tree.triggerHandler('checkboxChange', [$node, record, state]);
},
/**
* Event fires when the checkbox state is changed, but only once per click.
* @event changed
* @param {object} e - event data
* @param {object} $node - the node object as jQuery element
* @param {object} record - the record data
* @param {string} state - the new state of the checkbox
* @example Event.Sample <!-- checkbox, tree -->
* <div id="tree" data-source="/Locations/Get" data-checkboxes="true"></div>
* <script>
* var tree = $('#tree').tree();
* tree.on('changed', function (e, $node, record, state) {
* alert('This is only triggered once and the new state of record ' + record.text + ' is ' + state);
* });
* </script>
*/
changed: function($tree, $node, record, state){
return $tree.triggerHandler('changed', [$node, record, state]);
}
},

Expand Down