So, I keep expanding my bag of tricks for WordPress, and one of the tricks I have is a media uploader that be placed in a meta box or in widget settings by just adding a couple lines of HTML, jQuery does the rest from there. The problem I ran into was when a new widget was added the
click events were not bound to them, which is because the html for the widget is dynamically added, but you already knew that.
I dug into the WordPress jQuery code (/wp-admin/js/widgets.js to be exact) and found this:
This will allow you target the newly created widget with a function you’ve created:
Congrats, you have one less white hair today.