Reputation: 7167
Im catching the keys pressed in a meteor app at the $("body") level. But inside the keypress callback I want to have access to the data context but I don't know how to get to it.
Template.somename.rendered = function() {
$("body").keypress(function(e) {
e.stopImmediatePropagation();
// change stuff on the data context
From the template i'm accessing the data context as {{this.data}}.
Any ideas on how to go about it? Thank you in advance.
Upvotes: 0
Views: 161
Reputation: 64342
Template.somename.rendered = function() {
var self = this;
$("body").keypress(function(e) {
console.log(self.data);
e.stopImmediatePropagation();
});
};
Depending on what you are doing, you may be better off modifying some session data in your keypress
callback instead of directly manipulating the template, but it's hard to say without knowing more.
Upvotes: 1