流星模板未定义 [英] Meteor template.find is undefined
问题描述
我正在尝试使用 template.find
一个>使我的生活更轻松。
但是在javascript控制台中我得到: undefined不是一个函数
/ p>
这是我有的。它正在 template.find(...)
Template.superuserHUD.events =
{
'click input.new_device':function(template){
var id = template.find(。new_device_id)。
Device_IPs.insert({ID:id,IP:Not Connected});
}
}
任何想法?
事件处理函数接收两个参数: event
,一个包含事件信息的对象, code> template ,定义处理程序的模板的模板实例。
第二个参数是可选的,但是当您想使用模板实例函数(如 find()$)时,需要在处理程序中接收c $ c>,
findAll()
, firstNode()
和 lastNode() code>。
所以,要在你的事件处理程序中使用 template.find()
需要传递两个参数:
'click input.new_device':function(event,template){
//您的活动处理代码
}
I am trying to use template.find
to make my life easier.
But in the javascript console I get: undefined is not a function
Here's what I have. It is getting tripped up on 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"});
}
}
Any ideas?
The Event handler function receives two arguments: event
, an object with information about the event, and template
, a template instance for the template where the handler is defined.
The second parameter is optional, but it needs to be received in handler when you want to use template instance functions like find()
, findAll()
, firstNode()
and lastNode()
.
So, to use the template.find()
in your event handler, you need to pass both the arguments as:
'click input.new_device': function (event, template) {
// your event handling code
}
这篇关于流星模板未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!