流星模板未定义 [英] Meteor template.find is undefined

查看:139
本文介绍了流星模板未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 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() 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆