-
Notifications
You must be signed in to change notification settings - Fork 470
Description
Hello,
First of all, it is a great plugin to create switches easily.
I am using it to convert my checkbox to switch. Problem I am facing here is, I have a list of items in the datatable all has a switch element with it to make an ajax call. length of datatable is 10.
var switchElem = Array.prototype.slice.call(document.querySelectorAll('.toggle'));
switchElem.forEach(function (html) {
var switchery = new Switchery(html, { color: '#538bc0', secondaryColor: '#B2BABB' });
});
Using above code, It instantiates first 10 checkbox (first page of datatable) as a switch within datatable plus all other checkbox on the page that are visible on initial load. But it doesn't instantiate any checkbox that are not on first page of datatable. they remain as normal checkbox. So, if I navigate to second or any other page of datatable using datatable pagination, all checkbox are as default HTML checkbox.
I tried instantiating switch on datatable pagination event, but it duplicates the existing switches as well, and it doesn't instantiate switch when I navigate to second page for the first time. I have to open second page, go back to first page and again go to second page to see them as switch. (this is potentially datatable related thing)
Is there a way to instantiate the checkboxes that are not visible on page but are actually on the page?
Due to business constraints, I cannot provide a code.