Chih-Yu Yeh
Chih-Yu Yeh

Reputation: 65

Bootstrap Toggle with BootstrapDialog

Excuse me,

Is it possible to show Bootstrap Toggle in message field of BootstrapDialog?

For example:

BootstrapDialog.show({
  title: 'Information',
  message: '<input class="toggleExample" type="checkbox" data-toggle="toggle">'
});

Also, I tried to initialize $('.toggleExample') before BootstrapDialog and after BootstrapDialog, but they all didn't work.

Upvotes: 0

Views: 387

Answers (2)

dreamweiver
dreamweiver

Reputation: 6002

BootStrap dialog plugin is built on bootstrap 3 library similarly Bootstrap dialog is built on bootstrap 2 library.

so both the plugins work with different versions of core library, hence you cannot combine features of both plugins.

For more info refer plugins official site:

Upvotes: 1

K.Suthagar
K.Suthagar

Reputation: 2306

Just try this Code for your need, This will Popup with the Checkbox and Button.

BootstrapDialog.show({
    message: function (dialogItself) {
        var $form = $('<form></form>');
        var $titleDrop = $('<input type="checkbox" />');
        dialogItself.setData('field-title-drop', $titleDrop);   // Put it in dialog data's container then you can get it easier by using dialog.getData() later.
        $form.append('<label>Click Here</label>').append($titleDrop);

        return $form;
    },
    buttons: [{
        label: 'OK.',
        action: function (dialogItself) {
            alert(dialogItself.getData('field-title-drop').val());
        }
    }]
});

Try this Demo : http://jsfiddle.net/7DcHW/30/

Upvotes: 0

Related Questions