有人知道怎么解决这个问题吗。我有这段代码在删除文件时显示bootbox.confirm,但它不工作。
$('#fileupload').fileupload({
destroy: function (e, data) {
var that = $(this).data('fileupload');
if (bootbox.confirm("Delete this file(s) ?") == true ) {
if (data.url) {
$.ajax(data)
.success(function () {
$(this).fadeOut(function () {
$(this).remove();
});
});
} else {
data.context.fadeOut(function () {
$(this).remove();
});
}
}
}
});发布于 2014-08-27 22:50:58
Bootbox方法不像本机方法那样工作:
bootbox.confirm("Delete this file(s) ?", function(answer) {
if (!answer) return; // User said "no"
if (data.url) {
$.ajax(data)
.success(function () {
$(this).fadeOut(function () {
$(this).remove();
});
});
} else {
data.context.fadeOut(function () {
$(this).remove();
});
}
}发布于 2014-08-27 22:53:31
您必须使用回调来确定确认和提示对话框的用户响应。这是confirm的签名:bootbox.confirm(message, callback)。
你的代码应该是这样的
$('#fileupload').fileupload({
destroy: function (e, data) {
var that = $(this).data('fileupload');
bootbox.confirm("Delete this file(s) ?", function(result) {
if(result == true){
if (data.url) {
$.ajax(data)
.success(function () {
$(this).fadeOut(function () {
$(this).remove();
});
});
} else {
data.context.fadeOut(function () {
$(this).remove();
});
}
}
});
}
});https://stackoverflow.com/questions/25530209
复制相似问题