【发布时间】:2015-09-14 07:23:16
【问题描述】:
我试图覆盖 autoform-remove-item 按钮的按钮单击事件,如下所示,因为我试图显示警告消息(之前)用户可以删除 Autoform 数组中的任何项目。然后,如果用户确认删除项目,则按钮单击事件应正常继续。但我不知道如何覆盖按钮的单击事件,以暂停其下方的代码(我无权访问),直到用户确认/拒绝删除?有什么帮助我可能在这里遗漏的吗?谢谢
Template.salesInvoice.events({
'click .autoform-remove-item': function(e){
e.preventDefault();
bootbox.dialog({
message: "Are you sure you wish to delete this item?",
title: "New Journal",
buttons: {
eraseRecord: {
label: "Yes!",
className: "btn-danger",
callback: function() {
}
},
doNotEraseRecord: {
label: "No!",
className: "btn-primary",
callback: function() {
//Continue with the normal button click event
}
}
}
});
}
});
我试图覆盖的点击事件:
'click .autoform-remove-item': function autoFormClickRemoveItem(event, template) {
var self = this; // This type of button must be used within an afEachArrayItem block, so we know the context
event.preventDefault();
var name = self.arrayFieldName;
var minCount = self.minCount; // optional, overrides schema
var maxCount = self.maxCount; // optional, overrides schema
var index = self.index;
var data = template.data;
var formId = data && data.id;
var ss = AutoForm.getFormSchema(formId);
// remove the item we clicked
arrayTracker.removeFromFieldAtIndex(formId, name, index, ss, minCount, maxCount);
},
【问题讨论】:
标签: javascript meteor meteor-autoform