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

Trigger onChange on click #5

Open
JPustkuchen opened this issue Feb 21, 2018 · 1 comment
Open

Trigger onChange on click #5

JPustkuchen opened this issue Feb 21, 2018 · 1 comment

Comments

@JPustkuchen
Copy link

When using onChange like described in README.md:

onChange: function(element) {
  $(element).closest('td').css('background-color', element.checked ? '#73B355' : '#FFFACD');
}

The function is only triggered after dragging, not on click. It would be good to allow to also trigger onChange if the user only clicked one checkbox to allow a consistent callback. I tried to use clickToToggle: true for normal checkboxes but that just killed the check functionality at all on click (checkboxes are no more being checked).

I think this is expected behaviour in most cases. In the example above the table cells are only highlighted if they were dragged, but not if they were clicked, which is the same in result.

@JPustkuchen
Copy link
Author

JPustkuchen commented Feb 21, 2018

This is my jQuery workaround example, if it helps others. It uses the elements change event instead of dragCheck onChange ot act on every kind of change.

$('table :checkbox:not([readonly],[disabled])', context).change(function (e) {
  $(this).closest('td').css('background-color', $(this).is(':checked') ? 'green' : 'yellow');
}).dragCheck();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant