Trigger Submit Event when Widget is added to Sidebar

Based off the example @mrwweb provided above and some additional code, here is an answer that works. This answer forces a widget to save when a widget is added to a sidebar. It finds all the “Save” buttons and triggers their click event thus saving the widget. The count variable is used to stop an endless loop from occurring.

var count = 0;
$( document ).ajaxStop( function() {
    var $saveBtns = $('#products_sidebar, #blog_sidebar').find('.widget-control-save');
    if (count < $saveBtns.length) {
        $saveBtns.each( function( index, value ){
            $(value).trigger('click');
            count++;
        });
    }
    else {
        count = 0;
        return;
    }

} );

Leave a Comment