Meteor template.find is undefined

后端 未结 2 1651
轮回少年
轮回少年 2021-01-05 00:43

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. I

2条回答
  •  萌比男神i
    2021-01-05 01:22

    use a second arugment please like

    Template.superuserHUD.events
        'click input.new_device': (event, template) ->
            options =
                  id: template.find('.new_device_id').value
                  IP: 'Not Connected'
            Device_IPs.insert options
    

    and sometimes use template itself like

    Template.superuserHUD.events
        event: (event, template) ->
            @find('.new_device_id').value
    

    Here's the same in javascript for the coffee illiterate...

    Template.superuserHUD.events({
      'click input.new_device': function(event, template) {
        var options;
        options = {
          id: template.find('.new_device_id').value,
          IP: 'Not Connected'
        };
        return Device_IPs.insert(options);
      }
    });
    

    Template.superuserHUD.events({
      event: function(event, template) {
        return this.find('.new_device_id').value;
      }
    });
    

提交回复
热议问题