简体   繁体   中英

how can i use multi-select in bootbox

I want to use bootstrap-multiselect in modal. Im using a modal tools bootbox( http://bootboxjs.com/documentation.html ) to do this, but cant get it to work; because multiselect need init. But when I use it in box, I cant find anyway to write js in box.

How can I do this?

Js

$("#hello2").on("click", function () {
        var id = 0;
        bootbox.dialog({
            message:  '<div>ghostcard:<input type="text" name="first_name" id="ghostCard"/> </div><br> <div>water card:<input type="text" name="first_name" id="waterCard"/></div>   ' +
                    '       <select class="multiselect dropup" multiple="multiple" id="multiObject"> <option value="cheese">Cheese</option></select>',
            title:       "<small>hello</small>",
            buttons:{
                success:{
                    label:"confirm",
                    className:"btn-success",
                    callback:function () {
                        id = 2;
                        alert("id is " + id+$("#ghostCard").val()+$("#waterCard").val());
                    }
                },
                danger:{
                    label:"cancel",
                    className:"btn-danger",
                    callback:function () {
                        alert("id is " + id);
                        id = 3;

                    }
                }
            }


        });


    });

Hoping this will help, but I found you can call the message as a function to enable you to do init, etc. within and simply return the message result. So instead of the message as a string invoke is as a function; message: function () { // Create/Init Dropdowns return any text you want as the message. }

I found this very helpful for tying in functionality such as the json-editor within the actual dialog body.

All the best, Cheers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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