Init函数用于引导盒显示对话框后使用一些代码

Init function for bootbox to use some code after showing dialog

本文关键字:代码 对话框 显示 用于 函数 Init      更新时间:2023-09-26

我想用bootbox显示一个textarea元素。该文本区域应与所见即所得编辑器一起使用,该编辑器将由初始化

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

所以我想在文本区域显示的那一刻添加这个。我试过这个:

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

但这似乎是错误的。

只需添加一个显示事件:

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