Search code examples
jquerytwitter-bootstrapbootstrap-switch

Uncaught TypeError (jQuery) - setting readonly


I have a bootstrap-switch set up, I just want to set one of the items to read only.

I have tried:

$('#charge').bootstrapSwitch('setReadOnly', true);

But I get: Uncaught TypeError: Cannot read property 'apply' of undefined

The HTML is:

<input name="name1" type="checkbox" class="item-types"
       id="charge"
       data-size="large"
       data-indeterminate="true"
       data-on-text="YES"
       data-off-text="NO" />

What am I doing wrong?


Solution

  • Looks like you may have the first parameter wrong. Should be

    $('#charge').bootstrapSwitch('readonly', true);
    

    http://www.bootstrap-switch.org/options.html