Reputation: 23
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;
}
Upvotes: 1
Views: 3263
Reputation: 1612
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
Upvotes: 3
Reputation: 1342
Yeah, if you're trying to get the parent's data context you should be able to use the parentData() method on the Template instance. You probably don't even need that second template parameter.
'click .newContext': function(event) {
var parent_data = Template.parentData();
}
Upvotes: 0