流星为删除添加甜蜜警报
meteor add sweet alert for delete
我不知道在哪里以及如何放置删除线:
Clanovi.remove(this._id);
在甜蜜的警报中,我试过这样:
'click .btn-danger'()
{
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm){
if (isConfirm) {
Clanovi.remove(this._id);
swal("Deleted!", "Your imaginary file has been deleted.", "success");
}
else
{
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
}
这行不通,我不知道该怎么做。它不会删除。
很可能 this
不是您所期望的。尝试:
'click .btn-danger'()
{
let that = this;
console.log(that._id);
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm){
if (isConfirm) {
Clanovi.remove(that._id);
swal("Deleted!", "Your imaginary file has been deleted.", "success");
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
}
或者 - 您尚未设置 allow/deny 规则以允许在客户端上进行删除。
从安全角度来看,您最好调用方法来删除而不是在客户端上执行。
这是对我有用的示例:
const answer = await swal({
title: 'Are you sure?',
text: 'You will not be able to recover this imaginary file!',
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#dd6b55',
cancelButtonColor: '#d44',
confirmButtonText: 'Yes, delete it!',
cancelButtonText: 'No, keet it',
closeOnConfirm: false
})
如果用户确认
,答案将有{value: true}
我不知道在哪里以及如何放置删除线:
Clanovi.remove(this._id);
在甜蜜的警报中,我试过这样:
'click .btn-danger'()
{
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm){
if (isConfirm) {
Clanovi.remove(this._id);
swal("Deleted!", "Your imaginary file has been deleted.", "success");
}
else
{
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
}
这行不通,我不知道该怎么做。它不会删除。
很可能 this
不是您所期望的。尝试:
'click .btn-danger'()
{
let that = this;
console.log(that._id);
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm){
if (isConfirm) {
Clanovi.remove(that._id);
swal("Deleted!", "Your imaginary file has been deleted.", "success");
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
}
或者 - 您尚未设置 allow/deny 规则以允许在客户端上进行删除。
从安全角度来看,您最好调用方法来删除而不是在客户端上执行。
这是对我有用的示例:
const answer = await swal({
title: 'Are you sure?',
text: 'You will not be able to recover this imaginary file!',
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#dd6b55',
cancelButtonColor: '#d44',
confirmButtonText: 'Yes, delete it!',
cancelButtonText: 'No, keet it',
closeOnConfirm: false
})
如果用户确认
,答案将有{value: true}