Skip to content

Doesn't instantiate checkboxes on datatable #167

@harsh-r-dave

Description

@harsh-r-dave

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions