我正在使用一些href选项卡在html表中的所有行上绘制按钮.当用户单击行按钮时,它将使用HTML GET将用户重定向到另一个包含一些行值的PHP脚本.但是在我当前的实现中,当用户单击按钮时,没有确认.我添加了基本的javascript确认框,但它非常基本,浏览器要求每次都停止弹出警报.
因此,我没有使用普通的javascript,而是找到了bootbox.js专门为CSS警报和确认框设计的库.但是,当我使用当前的jquery实现应用bootbox方法时,它不起作用!
bootbox - bootbox文档
以下是我的代码:
这是我的href代码,它使html链接
echo "<a href='approveone.php?id=$lvid&empno=$empno<ype=$leavetype&hmd=$leavehmd&dprtmnt=$empdepartment&adminname=$adminusername' class='btn btn-success btn-xs m-r-1em confirmation' >Approve</a>";
Run Code Online (Sandbox Code Playgroud)
这是我的jQuery代码部分,包含bootbox调用.
<script type="text/javascript">
$('.confirmation').on('click', function () {
return bootbox.confirm('Are you sure?');
});
</script>
Run Code Online (Sandbox Code Playgroud) 我正在使用Bootbox为我的Web应用程序创建一个更好看的警报对话框.是否可以在警报对话框中居中对齐文本?
我正在尝试使用Twitter Bootsrap的bootbox.
在我使用的下面的代码中this.attr('href');,我得到了TypeError: this.attr is not a function.
当我改变到$(this).attr('href');我得到Undefined.
<a class="alert" href="list_users.php?id=123">Delete user</a>
<script src="bootbox.min.js"></script>
<script>
$(document).on("click", ".alert", function(e) {
e.preventDefault();
bootbox.confirm("Are you sure?", function(result) {
if (result) {
document.location.href = this.attr('href'); // doesn't work
document.location.href = $(this).attr('href'); // Undefined
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
任何的想法?
我正在尝试将bootbox.js添加到测试页面。
目前,当我在触发引导框的超链接中包含 href 标签时,无论我单击什么确认按钮(取消或确定),都会触发 href。
如何将 href 标签包含到 bootbox js 代码中,以便仅在用户选择 OK 确认选项时触发?我尝试了几次尝试,但都无济于事。
这是带有 href 标签的超链接:
<a id="id_customized_details_duplicate" href="{% url customized_details_duplicate customized_detail.id %}">Duplicate</a>
Run Code Online (Sandbox Code Playgroud)
这是我的书箱js代码:
$(document).ready(function(){
$('#id_customized_details_duplicate').on('click', function(){
bootbox.confirm("Are you sure?", function(result) {
if (result) {
//include the href duplication link here?;
//showProgressAnimation();
alert('OK SELECTED');
} else {
alert('CANCEL SELECTED');
}
});
});
});
Run Code Online (Sandbox Code Playgroud) 我有以下JS函数,可在弹出窗口中显示日期列表。
在返回所需数据的AJAX调用之后调用此函数。
function Show(currentSchedule) {
var scheduleDates = currentSchedule.Dates.join(", ");
bootbox.dialog({
title: "Preview",
message: "<div class='row'><div class='box'>" + scheduleDates + "</div></div>"
});
}
Run Code Online (Sandbox Code Playgroud)
单击按钮时将调用此选项,它将日期显示为逗号分隔的值。
为了以表格格式显示此内容,我查看了Datatables.js库。
它需要一个模板表,期望的数据将被注入其中。当您在页面上显示数据时,这很好用。
<table style="width:100%" id="previewTable" class="table table-striped table-bordered">
<thead>
<tr>
<th>
Date(s)
</th>
</tr>
</thead>
<tbody></tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚的是一种在弹出窗口而不是页面中显示表格的方法。
提前致谢。
Bootbox.js是否具有在成功显示对话框后调用函数的方法?
我最初计划使用它来将隐藏的表单从页面中的其他位置切换到Bootbox,但是如果没有回调或回调类比,就无法做到这一点。然后,我设计了一种移动隐藏表单的方法,在值得额头惊叹的瞬间,我意识到我仍然需要回调(或类比)来显示表单(删除“隐藏”类,添加“在班上)。
该文档似乎没有显示允许我执行此操作的内置属性(bootbox.init显示了诺言,但我没有完全理解,它没有示例记录,并且似乎是全局的。我使用了许多启动箱) 。我还有其他方法可以做到这一点吗?Bootbox是否发布某种事件?
我在bootbox v3文档中看到你可以使用下面的方法bootbox.alert(str message,str label,fn callback)更改标签自定义按钮文本,解雇后调用的回调,
但是在4.4版本上,此方法似乎不起作用,如何在警报消息上使用自定义按钮标签
我想用多行提示创建一个启动箱。这是默认示例:
bootbox.prompt({
title: "What is your real name?",
value: "makeusabrew",
callback: function(result) {
if (result === null) {
Example.show("Prompt dismissed");
} else {
Example.show("Hi <b>"+result+"</b>");
}
}
});
Run Code Online (Sandbox Code Playgroud)
但它只允许具有内联值。我需要显示多行值并输入多行文字。
我使用 bootbox 创建一个对话框,但我希望某些按钮仅在某些条件下显示。
我搜索了很多,但没有发现任何有用的东西..
我这样定义引导箱:
bootbox.dialog({
title: "title",
message: "text",
buttons: {
btn1: {
label: "Button 1",
callback: function () {
/* do something */
}
},
btn2: {
label: "Button 2",
callback: function () {
/* do something */
}
}
});
Run Code Online (Sandbox Code Playgroud)
我怎样才能让第二个 Button 只出现if(condition == true)?
之后我也尝试像这样删除按钮:
bootbox.dialog({...})
if(!condition) {
$('[data-bb-handler="btn2"]').remove();
}
Run Code Online (Sandbox Code Playgroud)
但没有成功。
任何想法表示赞赏!
格雷茨
我使用bootbox和jscolor,但是当我点击我的领域jscolor中,jscolor调色板是的后面bootbox.我怎么把它带到前面jscolor呢?