I am doing most of my coding in [appname].js at the root, and some third party libraries in app/client/compatibility
I am able to load these libraries, and declare and instantiate objects from them in my Template.template1.rendered handler, which works great.
However, when I want to modify one of the variables in Template.template2.events, specifically the event when a selector is changed. When I try to change it from here it tells me my variable is undefined.
I have tried declaring the variable at the top of the file, in isClient, but that doesn't seem to matter. There is no scenario where it is defined there.
So my question is how can I modify this variable in my Template.template2.events?
var something;
if ( Meteor.isClient ) {
function doSomething(some, value) {
some.property = value;
}
Template.template1.rendered = function() {
if(!this._rendered) {
this._rendered = true;
this.something= thirdParty.Create();
doSomething(this.something, document.getElementById("text").value);
}
}
Template.template2.events({
"change select" : function( event ) {
doSomething(this.something, input );
}
});
The something in the doSomething function says undefined when called from my change select event.