简体   繁体   English

从远程页面加载的模态上的Bootstrap-Switch

[英]Bootstrap-Switch on Modal loaded from remote page

I'm trying to use Bootstrap-Switch to toggle my checkboxes. 我正在尝试使用Bootstrap-Switch切换我的复选框。 It works fine on a normal page, or a modal thats pre-loaded into the page. 它在正常页面或预加载到页面的模式中正常工作。

However, if I load the modal from a remote page (a href=something.html) the toggle does not work/display. 但是,如果我从远程页面(a href = something.html)加载模式,则切换开关将不起作用/无法显示。 Apparently it loads once but doesn't reload after the modal is opened. 显然,它只加载一次,但在打开模态后不会重新加载。

I tried 我试过了

$("#myModal").on("shown.bs.modal",function(){
      $(".checkbox").bootstrapSwitch();
}); 

But to no avail. 但无济于事。

I've tried added the JS code directly to the code being pulled from the Modal as well but it didn't work. 我尝试过将JS代码直接添加到从Modal中提取的代码中,但是它不起作用。 It worked on the remote page when loaded directly, but not through the Modal. 直接加载而不是通过模式加载时,它可以在远程页面上运行。

I'm a novice JS guy so this may be a trivial fix. 我是JS新手,所以这可能是个小问题。 Basically need to know how to call bootstrapSwitch() after the modal is loaded. 基本上需要知道模态加载后如何调用bootstrapSwitch()。

Thanks! 谢谢!

Just realized I had the shown.bs.modal called 2x for different things. 刚意识到我有一个show.bs.modal被称为2x的东西。 When I combined, it fixed it. 当我合并时,它修复了它。 Bah, 30 minutes down the drain! ah,下水了30分钟!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM