user3142695
user3142695

Reputation: 17352

Init function for bootbox to use some code after showing dialog

I want to display a textarea-element with bootbox. This textarea should be used with a WYSIWYG-editor, which will be initialized by

$('#editor').redactor();

So I want to add this in the moment the textarea is displayed. I tried this:

bootbox.dialog({
    title: "Title",
    message: '<textarea id="editor"></textarea>',
    init: function () {
        $('#editor').redactor();
    }
});

But this seems to be wrong.

Upvotes: 2

Views: 3515

Answers (1)

user3848987
user3848987

Reputation: 1657

Just add a show event:

var box = bootbox.dialog({
    title: "Title",
    message: '<textarea id="editor"></textarea>'
});
box.bind('shown.bs.modal', function(){
    $("#editor").redactor();
});

Upvotes: 7

Related Questions