Bootbox Confirm Not Working
Bootbox Confirm Not Working
任何人都知道如何解决这个问题。我有这样的代码在删除文件时显示bootbox.conf,但它不起作用。
$('#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();
});
}
}
}
});
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();
});
}
}
您必须使用回调来确定用户对确认和提示对话框的响应。这是确认的签名: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();
});
}
}
});
}
});
相关文章:
- $rootScope not working
- jQuery document.ready not working
- Javascript getElementsByTagName not working?
- JQuery.val( ) not working
- Tomcat websocket is not working
- Javascript JSON.parse not working
- NodeJS Multer is not working
- Regex not working
- Ember run.debounce not working
- AngularJs 1 not working
- document.getElementById.style.backgroundImage not working
- Rxjs5, distinct() is not working
- createOscillator noteOn not working
- Javascript - .getHours() not working
- Javascript setTimeout not working | onkeydown
- MongoDB $pull not working
- Express router.use not working
- JSONP not working
- window.opener not working in chrome & IE
- Backbone + RequireJS: Collection.each() is not working