私のアプリでインターンメッセージを削除するイベントがあります:メソッドを呼び出すクリックイベントを含むボタンが前面にあります。すべてうまく動作します。Meteor.callはsweetalertの確認ボックス内で動作しません
しかし、このメソッドを呼び出す前に、「このメッセージを削除してもよろしいですか?
標準の確認js機能を使用すると、正常に動作します。しかし、標準のjs confirmbox ...スタイリングは許可されていません。
だから私のアイデアはsweetalertを使用していた:すべては、同様のBERT通知、うまく行くが、何のメッセージは削除されません。..
私のイベントの下には、ボックス版& sweetalertバージョン、および方法を確認します。
ありがとうございます!
確認ボックスバージョン
Template.Users.events({
'click .toggle-admin': function() {
Meteor.call('toggleAdmin', this._id);
},
'click button.delete-message':function() {
if(confirm('Are you sure?')) {
Meteor.call('deleteMessage', this._id, function(error) {
if(error) {
Bert.alert({
title: 'Error',
message: error.reason,
type: 'danger'
});
} else {
Bert.alert({
title: 'Success',
message: 'Message deleted.',
type: 'success'
});
}
});
}
}
});
sweetalertバージョン
Template.Users.events({
'click .toggle-admin': function() {
Meteor.call('toggleAdmin', this._id);
},
'click button.delete-message':function() {
swal({
title: "Are you sure?",
text: "You will not be able to recover this message!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!"
}).then(function(){
Meteor.call('deleteMessage', this._id, function(error) {
if(error) {
Bert.alert({
title: 'Error',
message: error.reason,
type: 'danger'
});
} else {
Bert.alert({
title: 'Success',
message: 'Message deleted.',
type: 'success'
});
}
});
})
}
});
方法
私はthis'は、あなたはそれがコールバックの内側にあることを期待しているものではありません '推測します。 – MasterAM
@MasterAMもっと具体的になりますか? – Ontokrat