Chained Selects #548

Closed
webarchitect0 opened this Issue Mar 29, 2012 · 6 comments

Comments

Projects
None yet
4 participants

Is there a best practice for creating Chained Selects with Chosen? I am using the CascadingDropDown from the asp.net Ajax Control Toolkit. Without Chosen the drop down is working the way I want but once Chosen is applied there are no values in either of my drop downs.

Thanks,

David

Collaborator

stof commented Mar 29, 2012

@webarchitect0 you need to trigger the liszt:updated event after changing the options of the select so that Chosen rebuilds the enhanced UI

nedone commented Apr 2, 2012

I am very interested in this topic.
Can you explain better how to do?

Thank you stof!

Hi nedone, your needs may vary from what I wanted to do but here is what I ended up doing:

$("#ItemCat").change(function () {
$("#Subcat").ajaxAddOption("DDLOptions.aspx?parent=" + $("#ItemCat").val(), {}, false, triggerUpdate, [{"dir":"desc"}]);
});

function triggerUpdate()
{
$("#Subcat").trigger("liszt:updated");
}

nedone commented Apr 2, 2012

tnx for your reply!
i use Chosen in wordpress... do you think is right to use your code for wordpress?

i try to explane:

i have:
Category01

  • subcat01-1
  • subcat02-2
    Category02
  • subcat02-1
  • subcat02-2

I want initially display only:
Category01
Category02

after select Category1-> display subcat01-1 & subcat01-2

Sure, you would have to change what I have to the IDs you use for your fields. That ajaxAddOption is an additional jquery plugin, I found it pretty useful. I was trying to do the exact same thing your trying to do.

nedone commented Apr 2, 2012

ok, it comforts me.
I use the plugin "https://github.com/scribu/wp-query-multiple-taxonomies" to filter my taxonomy ...
I have this template:
https://github.com/scribu/wp-query-multiple-taxonomies/blob/master/templates/dropdowns.html

where these are inserted #IDs?

pfiller closed this Apr 19, 2013

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