Search code examples
javascriptjquerytwitter-bootstrapbootstrap-switch

Bootstrap switch change event not firing when state is changed from 'false' to 'true' dynamically


I am using Bootstrap Switch in my project to show a warning flag. Each time I try to set value of switch from false to true dynamically it is not going in .bootstrapSwitch().on method. It is working fine on changing switch state from false to true dynamically. Fiddle below-

http://jsfiddle.net/aanurn0j/


Solution

  • Set third parameter to false and it works.

    $('#toggleSwitchOn').click(function () {
        $('#bootstrapswitch').bootstrapSwitch('state', true, false);
    });
    

    jsFiddle