I need to trigger the submit or "Save" button for a widget when the widget is added to a specific sidebar in the backend. The reason for this is I am setting a certain taxonomy for a Dropdown Menu inside each widget. The code for setting the taxonomy works fine as long as after adding a widget you hit the "Save" button or refresh the page after the widget has been added.
Here is my code inside jQuery I am using to capture the Ajax event when a widget gets added to a sidebar and to trigger the submit button to force a Save action.
$( document ).ajaxStop( function() {
var $saveBtns = $('#products_sidebar').find('input[submit]').trigger('submit');
} );
I am capturing the Ajax event correctly and able to console out the contents of the sidebar:
console.log("sidebar: " + $('#products_sidebar').html() );
However the submit action is not getting triggered.
thanks