Reputation: 453
I'm passing a data object to a template with iron-router but would like to access the data within the Template.name.rendered = function() { ... }
callback.
From Meteor data-context with iron-router I've tried UI.getData()
but receive an error There is no current view
. Using this.data
returns null.
How can I get access to the data object passed to the template from the rendered callback?
Upvotes: 1
Views: 190
Reputation: 1579
You were on the right track with looking for the data context, but this is actually how you get access to it:
var ctx = Template.currentData();
Also, I believe Template.x.rendered
is about to be deprecated, so if that doesn't work, try using
Template.x.onRendered(function() {
var ctx = Template.currentData();
console.log(ctx);
});
Upvotes: 1