Created
May 7, 2017 10:15
-
-
Save aldolat/c79a24eb9147d6f2fcc2f7a7dac7254e to your computer and use it in GitHub Desktop.
jQuery for WordPress events on widgets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Read here.