简体   繁体   English

Bootbox未显示弹出模式

[英]Bootbox not is not showing pop up modal

I have downloaded bootbox.js in my project and implemented this code to show the pop up modal dialog but nothing errors or success result is printed in my console.I am getting confusing where the error is generated. 我已经在项目中下载了bootbox.js并实现了此代码以显示弹出的模态对话框,但控制台中未打印任何错误或成功结果。我对产生错误的位置感到困惑。

Js file js文件

$('switch input[type="checkbox"]').on('change',function(){

        var checkbox=$(this);
        var checked=checkbox.prop('checked');
        var dMsg=(checked)? 'You want to activate the product':
                             'You want to deactivate the product';
        var value=checkbox.prop('value');

        bootbox.confirm({
            size: 'medium',
            title: 'Product Activation & Deactivation',
            message: dMsg,
            callback: function(confirmed){

                if(confirmed){
                    console.log(value);
                    bootbox.alert({
                        size: 'medium',
                        title: 'Information',
                        message : 'you are going to perform operation on product'+ value

                    });
                }
                else{
                    checkbox.prop('checked',!checked);
                }
            }

        });

    });

html file html文件

 <!-- toggle switch -->
        <label class="switch">
            <input type="checkbox" checked="checked" value="4" />
            <div class="slider"></div>
        </label>

You have used the wrong selector. 您使用了错误的选择器。 You used tag instead of class for 'switch'. 您将标记而不是类用于“开关”。 You need to use 您需要使用

$('.switch input[type="checkbox"]')

instead. 代替。

Ref. 参考 https://api.jquery.com/category/selectors/ https://api.jquery.com/category/selectors/

Also, make sure you have added the dependencies - jquery and bootstrap. 另外,请确保已添加依赖项-jquery和bootstrap。 Working version - http://jsfiddle.net/grrakesh4769/85etyhfc/3/ 工作版本-http://jsfiddle.net/grrakesh4769/85etyhfc/3/

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

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