我有一个骨干视图,在打印按钮上有一个点击事件,如下所示:
var updateInvoice=Backbone.View.extend({
template:_.template(mytemplate),
events:{'click #print':'print'},
print:function()
{
window.frames['contentIframe'].print();
}
});
现在的问题是,无论何时实例化上述视图,都会自动调用print函数,而无需等待click事件发生。
答案 0 :(得分:0)
尝试将该函数重命名为非标准名称,例如:
var updateInvoice=Backbone.View.extend({
template:._template(mytemplate),
events:{'click #print':'printInvoice'},
printInvoice:function()
{
window.frames['contentIframe'].print();
}
});