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

Bootstrap / MixItUp "data-toggle" Attribute Interference #268

Closed
UnrulyNatives opened this issue Dec 17, 2016 · 9 comments
Closed

Bootstrap / MixItUp "data-toggle" Attribute Interference #268

UnrulyNatives opened this issue Dec 17, 2016 · 9 comments

Comments

@UnrulyNatives
Copy link

Immediate children of An element in DOM which has a data-toggle="buttons" become activated and toggle visibility of the mixer's items.
Just to give more details, the frontend framework used by me is Bootstrap 4 alpha 5.

I attempted to add

controls: {
    scope: 'local'
}

to the initiating code, but the mixer didn't initialize with these lines.

I also tried to paste some code from MixItUp 2:

,
selectors: {

        filter: '.filter-btn',
        sort: '.sort-btn'
    }

but it didn't do any good either.

@UnrulyNatives UnrulyNatives changed the title some glitch with data-toggle attribute a glitch with data-toggle attribute Dec 17, 2016
@patrickkunka
Copy link
Owner

patrickkunka commented Dec 17, 2016

Hi,

I came across this issue a few days ago with another bootstrap user. Bootstrap uses the attribute data-toggle internally, which interferes with MixItUp.

Use the selectors.control configuration option to specify an additional selector by which to restrict MixItUp controls. This can be a class name or attribute etc.

e.g.

mixitup(container, {
    selectors: {
        control: '[data-mixitup-control]'
    }
}
<button type="button" data-mixitup-control data-filter=".red">Red</button>
<button type="button" data-mixitup-control data-toggle=".blue">Blue</button>
<button type="button" data-mixitup-control data-sort="default:desc">Sort Desc</button>

FYI - this option was added in 3.1.0

@patrickkunka
Copy link
Owner

Assuming this fix has worked for you, let me know if otherwise and will reopen.

@hannahmwool
Copy link

hannahmwool commented Feb 21, 2017

This fixes the issue but makes the MixItUp pagination buttons not work and since they're auto-generated I can't add the "data-mixitup-control" to each one. Is there a config option to add to that or should I use jQuery to add "data-mixitup-control" to each button after load?

Thanks

@patrickkunka
Copy link
Owner

patrickkunka commented Feb 21, 2017

Hi Molly,

Can you try the following? Haven't tried it but it should in theory work:

const mixer = mixitup({
    ...,
    templates: {
        pager: '<button type="button" class="${classNames}" data-page="${pageNumber}" data-mixitup-control>${pageNumber}</button>',
        pagerPrev: '<button type="button" class="${classNames}" data-page="prev" data-mixitup-control>&laquo;</button>',
        pagerNext: '<button type="button" class="${classNames}" data-page="next" data-mixitup-control>&raquo;</button>'
    }
});

@patrickkunka patrickkunka reopened this Feb 21, 2017
@hannahmwool
Copy link

Worked perfect! Thank you.

@patrickkunka patrickkunka changed the title a glitch with data-toggle attribute Bootstrap / MixItUp "data-toggle" Attribute Interference Jun 7, 2017
@Camran
Copy link

Camran commented Jun 29, 2017

Hi @patrickkunka issue is not solve, please help me.
var containerEl = document.querySelector('[data-ref~="mixitup-container"]');

        var mixer = mixitup(containerEl, {
            selectors: {
                target: '[data-ref~="mixitup-target"]'
            }
        });
         var mixer = mixitup(containerE1, {
         selectors: {
            control: '[data-mixitup-control]'
          }
     });

@patrickkunka
Copy link
Owner

patrickkunka commented Jun 30, 2017

Hi @Camran,

I don't understand what your question is. But you should only need to create one mixitup instance. You can merge all your configuration options together into a single configuration object.

var mixer = mixitup('[data-ref~="mixitup-container"]', {
    selectors: {
        target: '[data-ref~="mixitup-target"]',
        control: '[data-mixitup-control]'
    }
});

Does this help?

@Camran
Copy link

Camran commented Jul 4, 2017 via email

@leonel-ai
Copy link

Ran into the same issue. This (first suggestion) was exactly the solution I needed. Thanks @patrickkunka!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants