I’m writing a widget that uses color picker, whenever widget save the color picker will went missing. if i can add an event after the widget saved, then this problem can be solved easily. This is mainly because of the ajax call that occurred during the widget save. However, i can’t find any reference from the WordPress documentation. God bless, there jQuery come with some handy function that can be used as a work around to solve this problem 🙂
To add an javascript event after widget save, follow the steps below:-
Advertisements
- Save code below into a js file and enqueue the js file from your widget constructor
jQuery(document).ajaxSuccess(function(e, xhr, settings) { alert('my widget just saved'); // you may put your own action here });
- Now you may try to save your widget and you should see the alert pop up.
Happy coding 🙂
Related posts:
Redirect to maintenance page during upgrade using .htaccess
Prestashop 1.5 - How to enable add to cart button at Home Featured Product?
Meebo - The Ultimate Web base Instant Messenger powered by AJAX
WordPress WP-Cache with GZip Compression enable
Free Anti Virus for Mac OS X - ClamXav
How to write robot.txt to control search engine spider
WordPress Custom Taxonomy Pagination show 404 page not found error
How to configure Thunderbird for IMAP email?
Share this with your friends:-