javascript - Copy AJAX Control Toolkit CascadingDropDown on client -


i'd copy cascading dropdownlist on client side via javascript (jquery).

cascading drowndown lists

you can see in first box cascading dropdown lists replicate. rendered in asp.net cascadingdropdown control of ajax control toolkit. works perfectly.

when click on "add additional category" dropdownlists of firstbox copied. (see second box)

this click script action (using clone() of jquery):

categoryrow.clone(true, true).insertbefore(containerrow); subcategory1row.clone(true, true).insertbefore(containerrow); subcategory2row.clone(true, true).insertbefore(containerrow); subcategory3row.clone(true, true).insertbefore(containerrow); 

the clone() function copies hidden clientstate field of cascadingdropdown control.

unfortunately cascading functionality of copied cascadingdropdownlists not work.

how can best create/copy cascading drodwownlists? or have other ideas/better ways this?

"unfortunately cascading functionality of copied cascadingdropdownlists not work"

that because original elements registered event listeners... copied elements indeed copied but, without listeners.

how can check it? in modern browser (i preffer chrome) can watch elements of html page when entering development tools (hit f12 on). each element has map of active listeners.

element event listeners shown in chrome development tools

in short: find function used define events in first place original elements - use function register new copied elements.

just make sure not register original elements more once. cause each event fire several times each element.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -