Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor 如何在模板中引用模板?_Meteor_Meteor Blaze - Fatal编程技术网

Meteor 如何在模板中引用模板?

Meteor 如何在模板中引用模板?,meteor,meteor-blaze,Meteor,Meteor Blaze,我对meteorjs和web开发都是新手 我有两个模板,一个放在另一个里面。是否可以在模板中获取一个实例,以便在其中执行一些jquery操作 <template name="customTemplate"> <div> <button class="start">StartUpload</button> </div> </template> 启动负载 邮递 {{>customTemplate}} 发

我对meteorjs和web开发都是新手

我有两个模板,一个放在另一个里面。是否可以在模板中获取一个实例,以便在其中执行一些jquery操作

<template name="customTemplate">
  <div>
    <button class="start">StartUpload</button>
  </div>
</template>

启动负载


邮递
{{>customTemplate}}
发布新项目
Template.positem.events({
“click.buttonPost”:功能(e,模板){
//我想在这里获取customTemplate的实例,以便
//手动单击“开始”按钮
}
});
使用模板实例:

这是一个例子:

HTML:

这是一个普遍的例子。在你的场合:

Template.postItem.events({
  "click .buttonPost": function(e, template) {
      // I'd like to get the instance of customTemplate here so I can
      // manually click the "start" button
      Template.instance("customTemplate").$(".start").click();
  }
});

我不想直接从customTemplate中单击“开始”按钮。我想从postItem中单击“buttonPost”,然后模拟单击“start”按钮。我正在编辑我的答案,以使其更相关。只需使用Template.Instance,这正是我想要的!
<body>
  <h1>Welcome to Meteor!</h1>

  {{> hello}}
</body>

<template name="hello">
  <button class="sayHello">Click Me</button>
  {{> sayGoodbye}}
</template>

<template name="sayGoodbye">
<button class="goodbye">
        Goodbye
</button>
</template>
 Template.sayGoodbye.events({
    "click .goodbye":function(evetnt){
      console.log("sayGoodbye is clicked");
    }
  });

  Template.hello.events({
    "click .sayHello":function(event){
      Template.instance("sayGoodbye").$(".goodbye").click();      
    }
  });
Template.postItem.events({
  "click .buttonPost": function(e, template) {
      // I'd like to get the instance of customTemplate here so I can
      // manually click the "start" button
      Template.instance("customTemplate").$(".start").click();
  }
});