我正在尝试使用 template.find
让我的生活更轻松。
但在 javascript 控制台中我得到:undefined is not a function
这是我的。它在 template.find(...)
Template.superuserHUD.events =
{
'click input.new_device': function (template) {
var id = template.find(".new_device_id").value;
Device_IPs.insert({ID: id, IP: "Not Connected"});
}
}
有什么想法吗?
最佳答案
事件处理函数接收两个参数:event
,一个包含事件信息的对象,和template
,一个定义处理程序的模板的模板实例。
第二个参数是可选的,但是当你想使用模板实例函数如find()
, findAll()
, firstNode()
和 lastNode()
。
因此,要在您的事件处理程序中使用 template.find()
,您需要将两个参数都传递为:
'click input.new_device': function (event, template) {
// your event handling code
}
关于javascript - Meteor template.find 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13931196/