Fix reselecting option doesn't trigger 'change' event. #667

Closed
wants to merge 1 commit into
from

Projects

None yet

6 participants

@ryanwilliams

This fixes a bug where the 'change' event isn't triggered if you reselect the same option after clearing it.

Reproduce the bug:

  1. Have an instance with {allow_single_deselect: true} set.
  2. Have some JS listening for the 'change' event on the Select an option. (change event triggers) Click the 'x' to clear selection. (change event triggers) Select the same option again. (change event doesn't trigger)
@doits
doits commented Jun 10, 2012

if you're on it, you can also add the same fix when liszt:updated is triggered - see #672 for my fix in pure js (maybe calling val() is better than my proposal, I don't know atm)

@miguelm
miguelm commented Jul 4, 2012

+1 on this change, had to fork to get this fixed

@doits
doits commented Jul 5, 2012

I'm not sure: is this plugin dead (maybe author has no time to maintain it any more?). Would be nice to have a comment about this, because many fixes are waiting ...

@bojcan
bojcan commented Aug 20, 2012

Hi,

To fix it I added: this.current_value="" to the results_reset_cleanup() function. So it looks like that:

e.prototype.results_reset_cleanup = function () {
this.current_value = "";
return this.selected_item.find("abbr").remove() }

@stof
Collaborator
stof commented Sep 3, 2012

This should be fixed in the latest version of Chosen /cc @pfiller

@pfiller
Contributor
pfiller commented Sep 5, 2012

Thanks @ryanwilliams. This did get fixed in a recent commit to chosen/master. I didn't see this pull request when I was looking for a fix -- sorry about that.

Thanks again.

@pfiller pfiller closed this Sep 5, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment