I need to load a callback function after a wp.customize.previewer.refresh(). I need this because I want to update a template position which is displayed with a custom hook in my theme and scroll the preview frame on the new template position.

I use wp.customize.previewer.bind('synced', ...) but every time I change the position on my control, this bind event calls itself as many times as I change the position. So after the first position update on my control, the bind event calls itself once, but the second update calls the bind event twice and so on...

For your information I use WordPress 4.7.

  • 1
    It would be helpful if you included the existing code you're working with. – Weston Ruter Dec 10 '16 at 2:56

If you want to bind the callback from the customizer panel you can use:

wp.customizer.bind( 'preview-ready', callbackFn );

otherwise if you need to bind it from preview itself you can use:

wp.customize.previewer.bind('ready', callbackFn);
| improve this answer | |
  • I think the functions go the other way round. – Alvaro Mar 3 '19 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.