I am going crazy over and over again on the same topic, variable scope. Creating a global variable on this didn't work, I tried returning the value in one function to use the other one, but always get 'undefined' error back in the console. This is a simplyfied markup of the code:
domElement.plugin({
method1: function() {
// create variable
var myvar = 1;
// other things going on here in this method
},
method2: function() {
// use variable
console.log(myvar);
}
});
This is a jquery plugin where I am trying to access the value of var myvar created in method1 (and is variable) inside of method2. I have found several things here on the forums but can't seem to get any of them working, thus any help is more than appreciated.