I have a ReactiveVar that I need to read from and modify inside of an initialized jQuery plugin. Unfortunately I can’t find a way to call my template’s context inside of the jQuery event callbacks. This is all client side. I can’t use a Session here. Here is some code:
Setup my var
Template.player.onCreated(function(){
this.isPlaying = new ReactiveVar;
this.isPlaying.set('false');
})
Init my jQuery plugin
Template.player.onRendered(function() {
initPlayer()
});
relevant portion of initPlayer():
master = new TimelineMax({
paused: true
});
master.eventCallback("onUpdate", function() {
//Template.instance().isPlaying.set(false) //can't do this here
//reactive variables in jquery events are out of scope?
}
});
I have tried running the init function in an autotracker without any luck. I know I could use a Session here but I really want a reactive variable that will be destroyed along with the template. Any ideas of how to model this?