Hello, I am authoring a WP Widget plugin, and have run into a problem. My Widget’s Admin Form is quite involved, and uses an external javascript file to manipulate fields, collapse sections, etc. This external javascript is enqueued into the Widget Admin Panel like this:
function enqueue_admin_scripts() {
wp_register_script('mp3-admin-script', plugins_url('assets/js/wp-mp3-admin.js' , __FILE__ ), array( 'jquery' ));
wp_enqueue_script('mp3-admin-script');
}
add_action('admin_enqueue_scripts','enqueue_admin_scripts');
This works fine initially, but when you make a change to the Widget’s Admin Form and click the “Save” button, the page is reloaded but WITHOUT any of the JavaScript.
If I refresh the page, the javascript is loaded again and resumes working, but each time the Widgets’ changes are saved, the javascript stops functioning.
Any ideas why ‘admin_enqueue_scripts’ doesn’t get executed after a widget is “Saved”?
Thanks for looking!