WordPress.org

Make WordPress Core

Changeset 27969


Ignore:
Timestamp:
04/06/2014 07:05:03 PM (7 years ago)
Author:
ocean90
Message:

Widgets: Trigger jQuery events for widget updates.

  • widget-added when a widget is added to a sidebar
  • widget-updated when a widget is updated

A jQuery object of the widget is passed along to the event handler. Same events are used in the Widget Customizer, see [27909].

fixes #19675.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/widgets.js

    r26851 r27969  
    171171                    wpWidgets.save( $widget, 0, 0, 1 );
    172172                    $widget.find('input.add_new').val('');
     173                    $( document ).trigger( 'widget-added', [ $widget ] );
    173174                }
    174175
     
    375376                $('.spinner').hide();
    376377                if ( r && r.length > 2 ) {
    377                     $( 'div.widget-content', widget ).html(r);
     378                    $( 'div.widget-content', widget ).html( r );
    378379                    wpWidgets.appendTitle( widget );
     380                    $( document ).trigger( 'widget-updated', [ widget ] );
    379381                }
    380382            }
     
    440442        // No longer "new" widget
    441443        widget.find( 'input.add_new' ).val('');
     444
     445        $( document ).trigger( 'widget-added', [ widget ] );
    442446
    443447        /*
Note: See TracChangeset for help on using the changeset viewer.