Targeting a specific Wordpress widget form with jQuery -


i'm developing new wordpress widget. configuration form in widgets admin panel includes category , subcategory dropdowns (these not wordpress categories).

the values these dropdowns need retrieved via ajax, plus changing category dropdown should load new values subcategory dropdown via ajax. so, need use jquery target current dropdowns, , set handler change event.

how can right jquery selector in wordpress achieve this? user may add several of these widgets sidebar, can't use generic id or css class. or there more reasonable way code this, maybe using wp_localize_script?

there has unique factor amongst category dropdowns (since making selection there load options within subcategory).

i use data() method attach unique identifier (whether id, or whatever) each of these pulldowns, attaching class each of pulldowns (mywidgetname-category, or whatever).

then iterate on each of elements matches class, attaching change() event handler reads unique identifier attached using data(), , modifies appropriate subcategory select.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -