admin管理员组文章数量:1398281
I am trying to change state of bootstrap switch with condition return value from Ajax,
HTML,
<input type="checkbox" id="limit" class="make-switch" data-on-text="Yes" data-off-text="No" data-on="success" data-on-color="success" data-off-color="danger" data-size="small">
<input type="text" name="limit_amount" id="limit_amount" autoplete="off" class="form-control" readonly>
if(objData.limit === 'Yes')
{
$('#limit').bootstrapSwitch('setState', true);
$("#limit_amount").prop("readonly", false);
}
else {
$('#limit').bootstrapSwitch('setState', false);
$("#limit_amount").prop("readonly", true);
}
But it throw error as below .. Uncaught TypeError: Cannot read property 'apply' of undefined
Uncaught TypeError: Cannot read property 'apply' of undefined
at HTMLInputElement.<anonymous> (bootstrap-switch.min.js:22)
at Function.each (jquery.min.js:2)
at n.fn.init.each (jquery.min.js:2)
at n.fn.init.e.fn.bootstrapSwitch (bootstrap-switch.min.js:22)
at Object.success (limitingcat.js:311)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at y (jquery.min.js:4)
at XMLHttpRequest.c (jquery.min.js:4)
Is this bug of something wrong?
I am trying to change state of bootstrap switch with condition return value from Ajax,
HTML,
<input type="checkbox" id="limit" class="make-switch" data-on-text="Yes" data-off-text="No" data-on="success" data-on-color="success" data-off-color="danger" data-size="small">
<input type="text" name="limit_amount" id="limit_amount" autoplete="off" class="form-control" readonly>
if(objData.limit === 'Yes')
{
$('#limit').bootstrapSwitch('setState', true);
$("#limit_amount").prop("readonly", false);
}
else {
$('#limit').bootstrapSwitch('setState', false);
$("#limit_amount").prop("readonly", true);
}
But it throw error as below .. Uncaught TypeError: Cannot read property 'apply' of undefined
Uncaught TypeError: Cannot read property 'apply' of undefined
at HTMLInputElement.<anonymous> (bootstrap-switch.min.js:22)
at Function.each (jquery.min.js:2)
at n.fn.init.each (jquery.min.js:2)
at n.fn.init.e.fn.bootstrapSwitch (bootstrap-switch.min.js:22)
at Object.success (limitingcat.js:311)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at y (jquery.min.js:4)
at XMLHttpRequest.c (jquery.min.js:4)
Is this bug of something wrong?
Share Improve this question edited Dec 19, 2016 at 13:04 rjcode asked Dec 19, 2016 at 10:35 rjcoderjcode 1,3471 gold badge27 silver badges64 bronze badges 2- Can you share html as well; – itzmukeshy7 Commented Dec 19, 2016 at 13:00
- @itzmukeshy7, added HTML – rjcode Commented Dec 19, 2016 at 13:04
1 Answer
Reset to default 9Try this ;)
As far as I can tell the method has been updated (but not well documented).
$('#limit').bootstrapSwitch('state', true);
$('#limit').bootstrapSwitch('state', false);
https://stackoverflow./a/35375128/2922854 by @bplittle
本文标签: javascriptbootstrap switch setState gives js errorStack Overflow
版权声明:本文标题:javascript - bootstrap switch setState gives js error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744151238a2593067.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论