Is there a way to fire the onChange event when the select all is hit? If not, I need one please :-)
adding this code:
if (isSelectAllOption) {
var obj = this;
$target.parent().parent().parent().parent().children().each(function() {
var $option = obj.getOptionByValue($(this).find('input').val());
obj.options.onChange($option, checked);
});
}
to the function at line 369 - defined thus:
$('li input', this.$ul).on('change', $.proxy(function (event) { ... });
..fixes the issue.
Also, you probably wanna take this line:
this.options.onChange($option, checked);
and pop it into the !isSelectAllOption scope a few lines above it. That line fires the onChange event passing in undefined as the input element which could throw an exception if you don't check for that.
Thanks.
{Richard
I fully acknowledge that there is probably a better way of getting all the children than
$target.parent().parent().parent().parent().children()
..but I gotta move on in the project I'm working on.
Maybe an onSelectAllChange
configuration option would be interesting here.
I second @davidstutz proposition of implementing a separate event, if really necessary.
Generating a change event for each option would be way to slow, especially with a large number of options.
An alternative would be to listen for the change event on the original select (it's raised once after the selectAll finished its job) and check the selected values there?
I too am having a bit of trouble here - i am using the standard change event to show/hide data in my document. The select all / deselect all doesn't trigger the change event - is there any other way to hook onto it?
I assume an onSelectAll
option may be benificial here - will think about this.
馃憤 for this feature. We're currently live updating graphs when something is selected but unfortunately this doesn't happen when you select all filters in the dropdown.
I'm also interested in this feature. I see that there is already onSelectAll
, but it appears to accept no params. This fires when "select all" is used, and it would be usable if only it passed in the things it is selecting. But it doesn't, so my only alternative would be to scan the DOM looking at what is or isn't selected at the moment, instead of the select telling me what it selected (or deselected, in onDeselectAll
).
I agree a new event for each change is not warranted, but if onSelectAll
and onDeselectAll
had arguments, one of which was some sort of list of the changes, that would be sufficient for my purposes (which is to add or remove nodes from the DOM in a neighboring div whenever the multiselect is changed).
Also looking for an select all onChange event here 馃憤 . Thanks for implementing it!
@tangledhelix Ok, I guess it is possible to adapt onSelectAll
to provide some more information as parameters.
I am working with 6 multiselect's on the same form and need to get on which one was the SelectAll option chosen and I think I can't achieve that by the onSelectAll function or am I wrong?
Thanks !
Most helpful comment
Maybe an
onSelectAllChange
configuration option would be interesting here.