Since I’m saving everything on hard save ( button click ) I was trying to avoid updating all the options via ajax. What the below does is as the preview pane is setting up the JS binding, I trigger a “change” which will reapply the controls value to the element. I’m certainly open to better options but this worked in my case:
jQuery( document ).ready( function( $ ) {
// Body Background Color
wp.customize( 'body_bgr_color', function( control ) {
control.bind( function( value ) {
$( 'body' ).css( 'background-color', hex2rgba( value ) );
} );
$( control ).trigger( 'change' );
} );
} );
Related Posts:
- Customizer JS API
- Is it Possible to Extend WP Customize JS Methods?
- wp.customize.bind ready event not fired
- Detecting WordPress Customizer Panel
- WP Customizer set a value via javascript (to create presets)
- wp_customize_support_script – do I need it?
- Customizer – instantiating settings and controls via javascript
- Customizer JS API: Defining control settings
- Customizer JS API: Adding Setting Dynamically Not Working
- Customizer: When to use customize_preview_init VS customize_controls_enqueue_scripts
- How to overwrite JS variable with wp_localize _script?
- Theme Customiser not live previewing changes on pseudo elements
- the Customizer – proper way to instantiate an image upload control via javascript
- How to check if customize previewer is refreshing?
- JavaScript in WordPress Customizer
- Customizer JS API: Adding a “dropdown-pages” control
- Accessing customizer values in javascript
- Running JS after theme customizer finished initialization
- customize_preview_init: listening for any changes from Customizer preview area
- How to conditionally show/hide controls & sections in WordPress customizer?
- Multiple Conditional Controllers
- WordPress customizer get control
- Using webpack to add customizer live preview functionality – wp.customize is not a function
- Adding and removing hidden buttons from WordPress Customizer Tinymce widget editor using javascript API
- Get a default value of the Customizer setting using wp.customize API (JS)
- How to add customizer control via javascript ( wp.customizer.control.add )
- Load page in customizer preview on panel click?
- Customizer JS API: Defining active_callback for a section
- Adding Code into Theme Customizer Header
- Custom JS text area in customizer is being formatted wrong in document
- customize-controls.js – extend api.previewer
- Multiple jQuery inputs or binds in Customizer Control Javascripts
- Show sections based on a control in WordPress Customizer using JS API
- How do I add a class to Customizer preview based on class of Customizer control? (Customizer Javascript API)
- LayersWP Customizer White Blank Screen
- Get a default customizeAction text for a section using Customizer JS API
- Receive “menu-toogle” event from section menu in customizer
- Define a global variable in a JavaScript function
- Can’t bind to ‘ngModel’ since it isn’t a known property of ‘input’
- Cross-Origin Read Blocking (CORB)
- How can I remove a specific item from an array?
- How to use Redirect in the new react-router-dom of Reactjs
- How to fix “Cannot read property ‘addEventListener’ of null” error [duplicate]
- What does [object Object] mean?
- How can I create a two dimensional array in JavaScript?
- How can I refresh a page with jQuery?
- How can I create a two dimensional array in JavaScript?
- Does JavaScript pass by reference?
- How to add jQuery code into HTML Page
- How do I check for null values in JavaScript?
- Pure JavaScript: a function like jQuery’s isNumeric()
- jquery SlideToggle effect in upward direction?
- Deleting array elements in JavaScript – delete vs splice
- Node.js Error: connect ECONNREFUSED
- How to move an element into another element?
- Is there an arraylist in Javascript?
- How do I check if string contains substring? [duplicate]
- How to move all HTML element children to another parent using JavaScript?
- JavaScript – cannot set property of undefined
- Why is this jQuery click function not working?
- Simple average function in Javascript
- How to uncheck a radio button?
- How can I extract a number from a string in JavaScript?
- Angularjs: Error: [ng:areq] Argument ‘HomeController’ is not a function, got undefined
- Force div to be topmost element of any and all webpages
- moving an element in JS
- Is there a way to get element by XPath using JavaScript in Selenium WebDriver?
- Print a div content using Jquery
- How can JavaScript save to a local file?
- Generating PDF files with JavaScript
- What are the differences between JSON and JSONP?
- How do I call a JavaScript function on page load?
- Documentation for using JavaScript code inside a PDF file
- REST API: Backbone and custom endpoint
- Gutenberg custom block plugin with custom image sizes
- How to refresh Theme Customizer after change color inside wpColorPicker?
- Check user logged in with JS
- Can I make use of word-count.js in my own code?
- “Password Strength Unknown” Registration Issue
- Linking to Files in Root Directory Outside of WP Installation
- Only loads on the contact template page
- Min And Max Date With Date Format In Elementor Form Not Working
- Strange gibberish JavaScript in Editor – site hacked?
- Building a slide down search box in wordpress
- javascript conflict
- Shrink Header Image on Scroll
- How can I use CKEditor with WordPress and let clients edit the content?
- esc_js() breaks unicode sequences by removing the slash ‘\’ character
- Video script issue, JavaScript attribute remains ‘undefined’
- Why does a on Comment edit page submit the page?
- TinyMCE Javascript URL Question
- Setting Variable Path to Template Directory inside Script
- how to prevent added meta box from being injected with style=”position: fixed; top: 56px;” at scroll down
- How do i load javascript on a specific custom post template via functions.php?
- How to use value from modal tinymce windowManager?
- Can’t change javascript files
- Wysiwyg editor not working on 4.2.2
- Google Map JavaScript error after migrating
- How to load JavaScript modules with script_loader_tag hook?
- How to securely set dynamic HTML content with JavaScript?