简体   繁体   English

如何在事件内部执行onRendered函数?

[英]How to perform a function onRendered inside events?

How to perform a function onRendered inside events ? 如何在events内部执行onRendered函数? The sample code below does not work. 下面的示例代码不起作用。 How is the correct syntax? 正确的语法如何? If this is allowed, of course. 如果允许的话,当然可以。

Template.myTemplate.events({
  "click": function(event, template) {
    this.instance().onRendered(function() {
      alert('hello');
    });
  }
});

Using Google Translate. 使用谷歌翻译。

You can use Blaze.render . 您可以使用Blaze.render

If you just wanna get the data which bind to your item from your event handler, use 如果您只是想从事件处理程序中获取绑定到项目的数据,请使用

Blaze.getData(event.target)

Reference is here 参考在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM