[wp-trac] [WordPress Trac] #19675: Add a jQuery triggers to the widget save action

WordPress Trac noreply at wordpress.org
Sat Mar 22 21:02:21 UTC 2014


#19675: Add a jQuery triggers to the widget save action
---------------------------+-----------------------------
 Reporter:  digitalnature  |       Owner:
     Type:  enhancement    |      Status:  new
 Priority:  normal         |   Milestone:  Future Release
Component:  Widgets        |     Version:  3.3
 Severity:  normal         |  Resolution:
 Keywords:                 |     Focuses:
---------------------------+-----------------------------

Comment (by westonruter):

 Without a specific event which fires when a widget form gets replaced, it
 seems the de facto workaround is to hack `jQuery.ajaxSuccess` with checks
 for whether the the request for updating the widget. See an example at:
 http://wordpress.stackexchange.com/q/138355/8521

 In #27491 I've just supplied a patch which adds a `widget-form-update`
 jQuery event which fires on the widget's root element whenever the form
 gets updated (i.e. when it is saved on the widgets admin page), and when
 this event happens the widgets can re-initialize any dynamically-generated
 fields (such as Chosen select fields). The event is also triggered in the
 customizer, where there are both hard updates and soft updates depending
 on whether it is detected that live updates are supported.

 For an example of how such a widget may use this `widget-form-update`, see
 this sample plugin: https://gist.github.com/westonruter/9676069

--
Ticket URL: <https://core.trac.wordpress.org/ticket/19675#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list