• Resolved alexadark

    (@alexadark)


    Hi,
    i have 2 questions:
    i’m using the toggle control for 2 things
    – toggling a class to an element, so i have a styling which can be activated or deactivated, it works, but i don’t know how to have a preview in the customizer, even in transfert mode with page relaod it doesn’t appear
    and if possible i would live to have it with no reload (auto or postMessage)

    – toggling functions that displays elements, here it works but it reload the page, i would like to have post message, so i suppose that i need to hide the element, but i don’t see options for this.

    Thanks for your work, this plugin is really amazing !

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter alexadark

    (@alexadark)

    For the first point i have done it with js_vars and value_pattern , but this state doesn’t disappear if i change the toggle
    i have tried to write my own script

    
        wp.customize( 'center_header', function( value ) {
            value.bind( function( to ) {
                $( '.side-header' ).removeClass().addClass( to + ' centered' );
            } );
        });
    
    

    But it doesn’t work and i don’t find information on how to accomplish that

    • This reply was modified 7 years, 1 month ago by alexadark.

    @alexadark where is that script enqueued?
    It should be on customize_preview_init

    Thread Starter alexadark

    (@alexadark)

    Hi,
    it is:

    `add_action( ‘customize_preview_init’, ‘wst_customize_preview_js’ );
    /**
    * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
    */
    function wst_customize_preview_js() {
    wp_enqueue_script( ‘wst-customizer’, get_stylesheet_directory_uri() . ‘/assets/js/theme-customizer.js’, array( ‘customize-preview’ ), ‘1’, true );
    }`

    i have this in functions.php and my customizer files are called after this one:

    `// Include Kirki custom controls.
    require_once( CHILD_THEME_DIR . ‘/lib/customizer/include-kirki.php’ );

    // Include Kirki fallback.
    require_once( CHILD_THEME_DIR . ‘/lib/customizer/kirki-fallback.php’ );

    // WordPress Theme Customizer.
    require_once( CHILD_THEME_DIR . ‘/lib/customizer/customizer.php’ );`

    so it should work, i work on a genesis child themes
    so normally the code i have written should work ?

    • This reply was modified 7 years, 1 month ago by alexadark.
    • This reply was modified 7 years, 1 month ago by alexadark.
    Thread Starter alexadark

    (@alexadark)

    I post an answer but it doesn’t appear
    but basically yes

    add_action( 'customize_preview_init', 'wst_customize_preview_js' );
    /**
     * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
     */
    function wst_customize_preview_js() {
    	wp_enqueue_script( 'wst-customizer', get_stylesheet_directory_uri() . '/assets/js/theme-customizer.js', array( 'customize-preview' ), '1', true );
    }

    and my customizer files come afte

    // Include Kirki custom controls.
    require_once( CHILD_THEME_DIR . '/lib/customizer/include-kirki.php' );
    
    // Include Kirki fallback.
    require_once( CHILD_THEME_DIR . '/lib/customizer/kirki-fallback.php' );
    
    //  WordPress Theme Customizer.
    require_once( CHILD_THEME_DIR . '/lib/customizer/customizer.php' );

    So the code with add_class etc… should work ?

    Thread Starter alexadark

    (@alexadark)

    i am working on a genesis child theme btw

    @alexadark I’m sorry for the delay here, I completely missed your reply.
    Do you still have an issue with the latest version of the plugin?

    Since there has been no reply in 6 weeks I’ll go ahead and close this ticket.
    If you’re still having an issue please reopen this and I’ll do my best to reply ASAP.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘toggle, checkbox and previews’ is closed to new replies.