[wp-trac] [WordPress Trac] #31320: Make customizer JavaScript API available during the live preview

WordPress Trac noreply at wordpress.org
Thu Mar 19 13:10:56 UTC 2015


#31320: Make customizer JavaScript API available during the live preview
-------------------------+------------------------------
 Reporter:  Fab1en       |       Owner:
     Type:  enhancement  |      Status:  reopened
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Customize    |     Version:  4.1
 Severity:  normal       |  Resolution:
 Keywords:  needs-patch  |     Focuses:  javascript
-------------------------+------------------------------

Comment (by Fab1en):

 Replying to [comment:7 ocean90]:
 > [30891] has introduced a `preview-ready` event which you can use.

 Ok, this event can tell me when `wp.customize.preview` is defined. But
 more time is needed to initialize the listening part of the logic.

 In the customizer pane, I have this :

 {{{#!javascript
 wp.customize.previewer.bind( 'please-do-this-for-me', function(params){
     console.log('OK, I\'ll do it', params);
 } );
 }}}

 If I don't put a timer and send the event upon preview-ready event, it is
 not received.
 {{{#!javascript
 wp.customize.bind( 'preview-ready', function(){
     wp.customize.preview.send( 'please-do-this-for-me', 'first-param' );
 });
 }}}

 Is it possible that my event listening gets removed before preview is
 ready ?

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


More information about the wp-trac mailing list