Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/464.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 引导开关不适用于动态创建的复选框输入_Javascript_Jquery_Twitter Bootstrap - Fatal编程技术网

Javascript 引导开关不适用于动态创建的复选框输入

Javascript 引导开关不适用于动态创建的复选框输入,javascript,jquery,twitter-bootstrap,Javascript,Jquery,Twitter Bootstrap,我有以下脚本组合: jquery,bootstrap,modernizer,json2html 比如说: <script> $('#my01Switch').bootstrapSwitch({ onText: 'ON', offText: 'OFF', size: 'large', onColor: 'success', offColor: 'warning'

我有以下脚本组合: jquerybootstrapmodernizerjson2html

比如说:

<script>
   $('#my01Switch').bootstrapSwitch({
            onText: 'ON',
            offText: 'OFF',
            size: 'large',
            onColor: 'success',
            offColor: 'warning',
            labelText: '*'
        });
    </script>

$(“#my01Switch”).bootstrapSwitch({
文字:“ON”,
offText:“OFF”,
尺寸:'大',
onColor:“成功”,
offColor:“警告”,
标签文本:'*'
});
在结束正文标记之前,在:

<input name="my01Switch" id="my01Switch" data-toggle="switch" checked="" type="checkbox">

上面是动态生成的输入标记


请提供帮助。

在执行引导开关插件之前,检查文档是否准备就绪:

$(document).ready(function() {
    //Code
});
更新开关复选框代码:

将类添加到复选框中

<input name=\"my01Switch\" id=\"my01Switch\" type=\"checkbox\"  data-toggle=\"switch\" checked=\"true\" class=\"custom-box\"/>

是 啊正如你所提到的,我在准备好的文件中打电话。仍然不起作用。二:1.>不推荐使用/@来表示sourceMappingURL pragmas。使用//#而不是2.>不推荐使用getPreventDefault()。改用defaultPrevented。但是这些都在Jquery代码2.0.3中…您使用哪个Jquery版本?另外,你如何创建你的复选框,你能给我们看你的代码吗?你能直接把厨房代码添加到你的html页面上,看看这是否有效吗?它已经在页面上了。仅提供插件代码(js和css)的链接,请右键单击并查看源代码。如果你一直向下滚动,它会在下面。
function renderRooms(json)
{
    if (json !== undefined) {

        //.....

        //$('#roomBoxWrap').json2html(json, transforms.theRoom);
        $('#form-nav').json2html(json.rooms, transforms.menurooms);
        $('#title_room_name').append(getRoomName(json));

        //After the rooms are loaded
        $('.custom-box').bootstrapSwitch();
    }
}