Chain dynamically created dropdowns with JQuery

荒凉一梦 提交于 2020-01-06 03:38:45

问题


I'm building some kind of indefinite filters for an app, and I'm havin this problem when I clone some selects.

The things is this selects are chained between them, trough the Chained Selects jQuery plugin.

The problem is that every time I clone the selects, the chaining stops working, and I've tryed everything, such as .live() to make it work, but it seems I'm out of luck :D

Here you have a sample of what I'm talking about, http://jsfiddle.net/7K2Eu/63/

At first, the selects chain normally, but when I clone the form, they stop working, except for the first row of selects.

Thank you!!


回答1:


http://jsfiddle.net/FJFFJ/1/ i think this is what you search ;-)

I figured out that when you do the clone of the template you only clone the current existing template. thus if you made some choices and therefore the chaining reduced the set of selections you clone only that reduced set of selections.

I also figured out that cloning doesn't clone the chaining.

Also I changed your duplication support so that the chaining only is being applied to the new generated items.




回答2:


Hmz... seems a bit overly complicated...

Here's another example



来源:https://stackoverflow.com/questions/5545229/chain-dynamically-created-dropdowns-with-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!