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

Select All doesn't fire onChange event #415

Closed
nashtag opened this issue Oct 29, 2014 · 12 comments
Closed

Select All doesn't fire onChange event #415

nashtag opened this issue Oct 29, 2014 · 12 comments

Comments

@nashtag
Copy link

nashtag commented Oct 29, 2014

Is there a way to fire the onChange event when the select all is hit? If not, I need one please :-)

@nashtag
Copy link
Author

nashtag commented Oct 29, 2014

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

@nashtag
Copy link
Author

nashtag commented Oct 29, 2014

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.

@davidstutz
Copy link
Owner

Maybe an onSelectAllChange configuration option would be interesting here.

@Tyf0x
Copy link
Contributor

Tyf0x commented Dec 1, 2014

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?

@bogal
Copy link

bogal commented Jan 3, 2015

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?

@davidstutz
Copy link
Owner

I assume an onSelectAll option may be benificial here - will think about this.

davidstutz added a commit that referenced this issue Feb 13, 2015
@sverraest
Copy link

👍 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.

@tangledhelix
Copy link

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).

@Hyllesen
Copy link

Hyllesen commented Aug 28, 2017

Also looking for an select all onChange event here 👍 . Thanks for implementing it!

@davidstutz
Copy link
Owner

@tangledhelix Ok, I guess it is possible to adapt onSelectAll to provide some more information as parameters.

@khamulbr
Copy link

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 !

@davidstutz
Copy link
Owner

@tangledhelix better late then never, but this will be included with the next commit.

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

No branches or pull requests

8 participants