admin管理员组文章数量:1345452
I was wondering if there is a way to dinamically update the content of a bootbox modal.
Example
bootbox.dialog({
message: "Hi there",
title: "My title",
buttons: {
main: {
label: "dismiss",
className: "btn-primary",
}
}
});
newMessage = "this is a new message"
Is there a way to replace that "Hi there" with the new string newMessage?
Thanks for any help or suggestion
I was wondering if there is a way to dinamically update the content of a bootbox modal.
Example
bootbox.dialog({
message: "Hi there",
title: "My title",
buttons: {
main: {
label: "dismiss",
className: "btn-primary",
}
}
});
newMessage = "this is a new message"
Is there a way to replace that "Hi there" with the new string newMessage?
Thanks for any help or suggestion
Share asked Sep 11, 2015 at 14:43 Mirco LclMirco Lcl 3737 silver badges19 bronze badges3 Answers
Reset to default 8yes, you can change bootbox msg by adding id reference to the msg. Below is sample code for it.
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");
Simple! Create a generic function:
function bootBoxModal(title, message, type) {
bootbox.dialog({
message: message,
title: title,
alertType: type,
buttons: {
main: {
label: 'Fechar', className: 'btn-default'}
}
});
}
Call the function now:
bootBoxModal("Title message",
"Content your message",
"type [alert,danger,warning,success]");
Another solution is just to replace the content directly, this example uses jQuery.
#jQuery
$('.modal-title').html('New Title');
$('.modal-body').html('New Message');
本文标签: javascriptBootboxhow to dynamically change message contentStack Overflow
版权声明:本文标题:javascript - Bootbox - how to dynamically change message content? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743771531a2536213.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论