Chosen: Clone an existing chosen

Created on 24 Sep 2011  ·  8Comments  ·  Source: harvesthq/chosen

Hi,

Is there an easy way to clone an existing chosen select box?

Most helpful comment

Hi. I used some jQuery to make it work.

In your code where you add the cloned elements just add these:

$("#" + currentRow+ " select").removeClass("chzn-done").removeAttr("id").css("display", "block").next().remove();
$("#" + currentRow+ " select").chosen();

In my code I use currentRow to select only the last inserted form.

All 8 comments

I really need this feature...

Someone has done something similar?

Thanks!

That's really easy

oh yea?

I'd love to see this working, currently I have to resolve to dirty hacks. Basically I have to clone the whole element containing the chosen'ed dropdown list and the new one is no longer functioning.

I can't believe this is an uncommon requirement, I'm using this for a generic type of form where you can add more elements.

Hi. I used some jQuery to make it work.

In your code where you add the cloned elements just add these:

$("#" + currentRow+ " select").removeClass("chzn-done").removeAttr("id").css("display", "block").next().remove();
$("#" + currentRow+ " select").chosen();

In my code I use currentRow to select only the last inserted form.

@harfyt , it works!

@harfyt works well! Cheers!

Closing this since it is solved outside of Chosen code.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SFPink picture SFPink  ·  4Comments

gandarez picture gandarez  ·  5Comments

piercemcgeough picture piercemcgeough  ·  5Comments

mcclurem picture mcclurem  ·  4Comments

Jeckerson picture Jeckerson  ·  7Comments