Jquery Chosen and knockout problems

2,327 views
Skip to first unread message

Voltron

unread,
Sep 4, 2012, 4:22:45 AM9/4/12
to KnockoutJS
I am havng probnlems with getting Jquery chosen(http://
harvesthq.github.com/chosen/) to work with knockout.js. The normal
select works well alone, but as soon as I couple it with Chosen, the
option tags are not rendered and the select is empty, I have tried
several postions of initialization, no success,

1. Can anyone show me how I can get both to work together?
2. Is there a standard way to get styling plugins to work with KO?

Thanks

Ragesh

unread,
Sep 4, 2012, 6:05:33 AM9/4/12
to knock...@googlegroups.com
I've had better luck with select2. It includes a KO binding, too. See http://ivaynberg.github.com/select2/

Voltron

unread,
Sep 4, 2012, 11:19:37 AM9/4/12
to KnockoutJS
Thanks Ragesh! :)

On Sep 4, 12:05 pm, Ragesh <rag...@rageshkrishna.com> wrote:
> I've had better luck with select2. It includes a KO binding, too. Seehttp://ivaynberg.github.com/select2/

vladimir...@gmail.com

unread,
Sep 17, 2012, 4:54:55 PM9/17/12
to knock...@googlegroups.com
You can try this solution http://jsfiddle.net/nittis/gzUtU/

steve...@gmail.com

unread,
Sep 26, 2012, 2:07:04 PM9/26/12
to knock...@googlegroups.com
I found that it works as long as you call chosen after the ko binding is complete.  For instance, in my viewmodel I have this:
                self.Users(company.Users);
                $('select').chosen(); // Chosen must be after the ko bindings or the list won't bind correctly
Now the select works with ko and chosen.  In my case this is a single-select, not sure if it would be the same for multi-select.  Thankfully it as a simple change once I figured out Chosen is what made my select quit working.

Alpine Scrambler

unread,
Sep 26, 2012, 6:39:24 PM9/26/12
to knock...@googlegroups.com
Just create a binding handler for it: http://jsfiddle.net/ericpanorel/zJaNa/

steve...@gmail.com

unread,
Jun 4, 2013, 7:17:16 PM6/4/13
to knock...@googlegroups.com, steve...@gmail.com
Today I discovered that sometime between Chosen version 0.9.8 and 0.9.12 the ability to use it with Knockout broke.  I updated mine today and pages that were working fine before no longer bind correctly in Knockout so the model property that the dropdown is bound to never gets updated.  At the moment I'm just going to go back to using an older version of Chosen.
Reply all
Reply to author
Forward
0 new messages