1
我正在嘗試製作一個彈出框,確認是否要刪除文檔。如果我嘗試:Alertify確認不適用於Ember js
if(alertify.confirm("Delete this?')) {
this.store.findRecord('document', docId, {backgroundReload: false}).then((doc) => {
doc.destroyRecord();
alertify.success('Document successfully deleted!');
}
因爲alertify.confirm是非阻塞的,所以它在運行刪除代碼之前不會等待確認,據我所知。如果我嘗試:
deleteFile(docId) {
alertify.confirm("Are you sure you want to delete this document?", function (e) {
if (e) {
this.store.findRecord('document', docId, {backgroundReload: false}).then((doc) => {
doc.destroyRecord();
alertify.success('Document successfully deleted!');
});
} else {
alertify.error('Something went wrong!');
}
});
}
它並請求確認,但刪除部分代碼不起作用,因爲店裏快到了爲未定義,所以findRecord不起作用。我已經嘗試將商店注入服務,但這也不起作用。有沒有辦法讓這個確認框工作?
完美的作品,爲解釋的感謝! –