bootstrap-switch
bootstrap-switch copied to clipboard
how to set the state on .ready?
I need to set the state. the checked value in html doesnt work and also how to change the state after loading a page? thanks in advance
I just noticed this as well when updating to 3.4 from 3.3.4. Even though I have 'checked' or 'unchecked' specified in the html for each input this new version doesn't respect them at all. This worked perfectly fine with version 3.3.4.
Do we have to manually set the check state in js for every input now? If so, that is a pretty dumb change.
Hi,
Same here, it works on 3.3.5 but not on 3.4 branch using AngularJS.
@StepIg have you set the on or off text ? When I use default value on these fields, I don't have the bug, can you confirm ?
Nicolas
Hi, Is the problem fixed yet? I still cannot create and show the switch in the ON state.
sample code:
let whatever_toggle = $(<input type="checkbox" name="whatever-toggle" class='whatever_toggle'></input>
);
$(parent_elem).append(whatever_toggle);
// ....
$(".whatever_toggle").bootstrapSwitch({
state: true,
// size: null,
size: 'mini',
// animate: true,
onColor: 'primary',
offColor: 'danger'
// .....
});
i tried the defaults in: size, onColor , offColor but still remains [OFF] ..
btw, i'm using CDN links to BOOTSTRAP 4.3.1 and to jquery-3.4.1.min.js