2017-02-17 18 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"); 
     } 
    }); 

} 

ИЛИ - вы не установили свои правила allow/deny, чтобы разрешить удаление на клиенте.

С защитой pov вам лучше позвонить методом удаления, а не делать это на клиенте.