我可以在事件函数中获取模板父数据上下文吗? [英] Can i get the template parent data context in the event function?

查看:53
本文介绍了我可以在事件函数中获取模板父数据上下文吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很想了解模板数据上下文. 我可以做这样的事情吗?

I'd love to get my hands on a templates data context. Can I do something like this?

'click .newContext': function(event, template) {
    var template_parent = template.parent();
    var parent_data = template_parent.data;
}

推荐答案

您可以使用Template.parentData(0),该参数定义您想走的深度,如果不进行任何设置,则默认值为0.请查看以下文档: http://docs.meteor.com/#/full/template_currentdata

You can use Template.parentData(0), the argument defines how deep you want to go, if you pass none, 0 is the default. Check the documentation on this: http://docs.meteor.com/#/full/template_currentdata

这篇关于我可以在事件函数中获取模板父数据上下文吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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