Skip to content

Instantly share code, notes, and snippets.

@aldolat
Created May 7, 2017 10:15
Show Gist options
  • Save aldolat/c79a24eb9147d6f2fcc2f7a7dac7254e to your computer and use it in GitHub Desktop.
Save aldolat/c79a24eb9147d6f2fcc2f7a7dac7254e to your computer and use it in GitHub Desktop.
jQuery for WordPress events on widgets.
jQuery(document).on('widget-updated', function(event, widget){
var widget_id = jQuery(widget).attr('id');
// any code that needs to be run when a widget gets updated goes here
// widget_id holds the ID of the actual widget that got updated
// be sure to only run the code if one of your widgets got updated
// otherwise the code will be run when any widget is updated
});
jQuery(document).on('widget-added', function(event, widget){
var widget_id = jQuery(widget).attr('id');
// any code that needs to be run when a new widget gets added goes here
// widget_id holds the ID of the actual widget that got added
// be sure to only run the code if one of your widgets got added
// otherwise the code will be run when any widget is added
});
@aldolat
Copy link
Author

aldolat commented May 7, 2017

Read here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment