在Bootbox中,我无法更改确认框的按钮颜色,请帮帮我
这是我的代码:
bootbox.confirm('This action removes all partners from this project and resets all existing stock distribution. <br /> <br /> Do you wish to continue?','Cancel','Remove', function (result) {
if (result == true) {
//do something
}
});
最佳答案
bootbox
允许您向按钮添加类。有关工作示例,请参见以下代码片段。将所需的样式放入css文件中,或者更好地使用标准引导程序颜色以保持一致性。在示例中,我使用了btn-danger和btn-default引导程序类以及pull-right和pull-left,但是您可以使用任何所需的类
如果您仍然遇到问题,也许您在bootbox和bootstrap和jquery版本之间不匹配?
bootbox.confirm({
message: 'This action removes all partners from this project and resets all existing stock distribution. <br /> <br /> Do you wish to continue?',
buttons: {
'cancel': {
label: 'Cancel',
className: 'btn-default pull-left'
},
'confirm': {
label: 'Remove',
className: 'btn-danger pull-right'
}
},
callback: function(result) {
if (result) {
// whatever you want to do here
console.log(result)
}
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script src="https://github.com/makeusabrew/bootbox/releases/download/v4.4.0/bootbox.min.js"></script>