[wp-trac] [WordPress Trac] #27491: Widget Customizer: Dynamically-created inputs cause from to replace itself without event to trigger re-initialization
WordPress Trac
noreply at wordpress.org
Fri Mar 28 08:33:03 UTC 2014
#27491: Widget Customizer: Dynamically-created inputs cause from to replace itself
without event to trigger re-initialization
--------------------------+-------------------------
Reporter: westonruter | Owner: ocean90
Type: defect (bug) | Status: reviewing
Priority: normal | Milestone: 3.9
Component: Widgets | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch | Focuses: javascript
--------------------------+-------------------------
Comment (by westonruter):
Replying to [comment:4 adamsilverstein]:
> I tried testing [attachment:27491.2.diff] - after installing I lose live
updating between the widget and the preview:
([http://f.cl.ly/items/0b0n041z3Z0z17192w22//Users/adamsilverstein/Library/Containers/com.monosnap.monosnap/Data/Library/Monosnap/.tmp/screencast%202014-03-27%2022-26-01.mp4
screencast])
Sorry, I had a logic error in my patch. Refreshed. Change was
https://github.com/x-team/wordpress-
develop/commit/2da26f8c35ed16062581fe320182d802f363e6a0
Replying to [comment:4 adamsilverstein]:
> can we just use triggers on add new widget and save widget? like -
>
> jQuery( document ).trigger( 'customizer-widget-added', [widget] );
> jQuery( document ).trigger( 'customizer-widget-saved', [widget] );
>
> we have similar triggers in heartbeat and autosave, they will get real
hooks when we add those to core but these should work for now.
That's right. This is what the patch introduces, though a bit differently.
Whenever the form is re-rendered, it executes:
{{{
event_data = {
'widget_id': control.params.widget_id,
'widget_id_base': control.params.widget_id_base,
'new_form': r.data.form,
'hard': ! control.live_update_mode, // dynamic fields may need to
be re-initialized (e.g. Chosen)
'customize_control': control
};
widget_root.trigger( 'widget-form-update', [ event_data ] );
}}}
(How this gets triggered, on which element and with what parameters, is of
course up for discussion.)
In the context of the customizer, it doesn't make so much sense to trigger
update when the settings are saved, because the widget form gets submitted
any time a change is made to a field (even several times while typing into
a single field). And anyway, for dynamic fields, the concern is more for
when the widget form gets ''updated'' rather than when the widget gets
''saved'', as the need is to know when the form needs to be re-initialized
for any dynamic fields.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27491#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list