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

Does not work with Knockout.js #604

Closed
inadarei opened this issue May 2, 2012 · 3 comments

Comments

@inadarei
Copy link

@inadarei inadarei commented May 2, 2012

Knockout.js is an amazingly great MVVM framework http://knockoutjs.com/

Alas, Chosen does not work with it at all. I can see in DOM that Knockout is properly updating the select element, but Chosen is showing its corresponding "dropdown" as disabled and empty :(

Tried to force Chosen to update with $("#genre").trigger("liszt:updated"); but did not help. Even put .trigger() in a 5sec timeout, to make sure Knockout async binding is not racing with the trigger, but still no dice.

Really out of options here. Would very much appreciate any help/insight.

Thanks

@inadarei

This comment has been minimized.

Copy link
Author

@inadarei inadarei commented May 2, 2012

Found an extremely elegant solution, courtesy of John Earles (http://bit.ly/JUn22k)

http://jsfiddle.net/jearles/avSfa/

Works like a charm!

@inadarei inadarei closed this May 2, 2012
@pfiller

This comment has been minimized.

Copy link
Contributor

@pfiller pfiller commented May 2, 2012

Thanks for sharing @inadarei -- this might be useful to others and it'll be good to have an answer here.

@marlonbernardes

This comment has been minimized.

Copy link

@marlonbernardes marlonbernardes commented Jul 23, 2013

I just had this issue (knockout bindings were not working for chosen 1 out of 5 times the page was loaded) and the cause was that chosen was being loaded after knockout. Since I was using requirejs for module loading, all I had to do was set up "chosen" as a dependency for knockout. Something like this:
[...]
shim : {
'knockout' : [ 'jquery.chosen' ],
[...]
}

I did not really dig into this issue, but it's not happening anymore after this fix. I know this is a specific setup (knockoutjs + chosen + requirejs), but I hope that helps somebody.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.