Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with replace single class #1196

Closed
sododesign opened this issue Dec 10, 2016 · 4 comments
Closed

Problem with replace single class #1196

sododesign opened this issue Dec 10, 2016 · 4 comments
Milestone

Comments

@sododesign
Copy link

Issue description:

Hi @aristath
I can not find a way to replace a single standard class with a value in a select customized with partial refresh.

I have a situation where I have a section with three classes. One of these 'defColor' is that which is changed through the use of a select in the customizer.

My problem is that when you return, all classes and the content of the section is deleted, leaving only the value of my select.

You can change only a specific class, leaving unchanged the rest? I tried through value_pattern but without any success.

Version used:

stable 2.3.7

Using theme_mods or options?

theme_mods

Code to reproduce the issue (config + field(s))

Kirki::add_field( 'wedding_day', array(
        'type'        => 'select',
        'settings'    => 'box_couple',
        'label'       => __( 'Change color section', 'goweddy' ),
        // 'help'        => __( 'Set the style and design of the website', 'goweddy' ),
        'panel'       => 'manage_section',
        'section'     => 'edit_couple',
        'default'     => 'defColor',
        'priority'    => 1,
        'choices'     => array(
            'defColor'    => __('Default Color','goweddy'),
            'altColor'    => __('Alternative Color','goweddy'),
        ),
        'transport'   => 'postMessage',
        'js_vars'     => array(
            array(
                'element'       => '#couple',
                'function'      => 'html',
                'attr'          => 'class',
                'value_pattern' => '%defColor%',
            ),
        ),
        'partial_refresh' => array(
            'partial_box_couple' => array(
                'selector'        => '#couple',
                'render_callback' => function() {
                    return get_theme_mod( 'box_couple' );
                },
            ),
        ), 
    ));

My HTML/PHP code:

<section id="couple" class="highSpace <?php echo get_theme_mod('box_couple', 'defColor'); ?> pattern0">
    <div class="container">
        .....
    </div>
</section>
@aristath aristath modified the milestone: 2.4.0 Dec 10, 2016
@daviedR
Copy link

daviedR commented Dec 12, 2016

Hi @sododesign, I got your email for help.

I think currently Kirki postMessage couldn't change class. You might need to do it manually using your own javascript.

@aristath
Copy link
Contributor

This is still a work in progress....
The rewrite of Kirki in the develop branch has some issues to resolve, but this will be included in the final release.

@sododesign
Copy link
Author

Thanks @daviedR and @aristath :)

@aristath
Copy link
Contributor

See comment on #1137 (comment)

@aristath aristath modified the milestones: 2.4.0, 3.0 Mar 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants