내 앱에서 인턴 메시지를 삭제하는 이벤트가 있습니다. 바로 앞에 버튼이 있으며 메서드를 호출하는 클릭 이벤트가 있습니다. 모든 것이 잘 작동합니다.Meteor.call이 sweetalert 확인 상자에서 작동하지 않습니다.
하지만이 메서드를 호출하기 전에 확인 상자가 나타납니다. "이 메시지를 삭제 하시겠습니까?"
표준 확인 js 기능을 사용하면 정상적으로 작동합니다. 하지만 표준 js confirmbox ... 스타일링은 허용되지 않습니다.
그래서 내 생각은 sweetalert를 사용하는 것이었다 : 모든 상자 버전 & sweetalert 버전 및 방법을 확인, 내 이벤트 아래
.. 어떤 메시지가 삭제되지 않습니다뿐만 아니라 잘 berts 알림을 이동하지만.
감사합니다.
확인 상자 버전
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'
});
}
});
})
}
});
방법
Meteor.methods({
insertMessage: function(message) {
ContactMessages.insert(message);
},
deleteMessage: function(messageId) {
ContactMessages.remove({_id: messageId});
}
});
내가 this' 당신이 그것을 콜백 내부 것으로 기대하고 무엇을하지 않습니다'같아요. – MasterAM
@ MasterAM 좀 더 구체적으로 말씀해 주시겠습니까? – Ontokrat