Bootbox - 如何动态更改邮件内容?

时间:2015-09-11 14:43:37

标签: javascript html twitter-bootstrap bootbox

我想知道是否有办法以dinamically方式更新bootbox模式的内容。

实施例

bootbox.dialog({
        message: "Hi there",
        title: "My title",
        buttons: {
            main: {
                label: "dismiss",
                className: "btn-primary",
            }
        }
    });


    newMessage = "this is a new message"

有没有办法用新字符串newMessage替换“你好”?

感谢您的任何帮助或建议

2 个答案:

答案 0 :(得分:5)

是的,您可以通过向msg添加id引用来更改bootbox消息。下面是它的示例代码。

    bootbox.dialog({
       message: "<span id='dynamicMsg'>Hi there</span>",
       title: "My title",
       buttons: {
        main: {
            label: "dismiss",
            className: "btn-primary",
        }
      }
    });

    //Add this line wherever you want to change msg
    $("#dynamicMsg").text("This is dynamic msg");

答案 1 :(得分:2)

简单!创建一个通用函数:

13

立即调用该函数:

function bootBoxModal(title, message, type) {
    bootbox.dialog({
        message: message,
        title: title,
        alertType: type,
        buttons: {
            main: {
                label: 'Fechar', className: 'btn-default'}
        }
    });
}