Bttstrp / bootstrap-switch

Turn checkboxes and radio buttons in toggle switches.
MIT License
5.08k stars 1.45k forks source link

bootstrap switch check box is not display ON when I have refreshed the page with value TRUE #709

Open JigneshPatel04 opened 5 years ago

JigneshPatel04 commented 5 years ago

I have used bootstrap-switch for display checkbox on/off It is working when I have switched on or off but when I have get value from database and I assigned value checked on input checked box then it is not display on.

checkbox <input data-id="{{id}}" type="checkbox" {{#if approved}} checked {{/if}} name="approved">

DSpeichert commented 5 years ago

Duplicates #703 It appears to work at v3.3.4 and breaks in v3.3.5.

souzaemarcal commented 5 years ago

Solved here with this:

$(function() {
    $('[data-switch="true"]').each(function () {
        $(this).bootstrapSwitch({ state: $(this).is(':checked') }).trigger('change');
    });
});