dimanche 3 avril 2016

Run Switchery, Select2 and wpColorPicker jQuery plugins in dynamically new elements

I'm working on a tiny wordpress plugin has a repeater which has some jQuery controls like Switchery, Select2, uploadMedia and wpColorPicker.

Is there a way to run event handlers for each control once in js file like Upload Media, it was very easy to bind it once for all new controls with this line

$('body').on('click', 'a.btn_media_upload', function (e) { });

All jQuery controls need an inline script for each once and i think it's not good, I test DOMNodeInserted but it didn't work and i read it's deprecated, Then i try to use the new way MutationObserver but unfortunately i failed to use it :)

Thanks for your help!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire