2017-02-17 102 views
0

我不知道在哪里以及如何把删除行:流星加甜警惕删除

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"); 
     } 
    }); 

} 

这不工作,我有不知道如何做到这一点。它不会删除。

回答

0

赔率是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"); 
     } 
    }); 

} 

或者 - 您尚未设置允许/拒绝规则以允许删除客户端。

从安全性角度来看,您最好调用一种删除方法,而不是在客户端上进行删除。