I'm using requireJS with googlemaps. I'm using plugin to load google maps: https://gist.github.com/taktran/5389668 (google maps api should be loaded with jQuery promise)
I have problem with "this" scope. Here is my code:
//funcs.js file
define('myFuncs', ['jquery', 'googleMaps'], function ($, googleMaps) {
var myFuncs = {
myVar="true";
init: function () {
googleMaps(this.map_init);
},
map_init:function () {
//scripts after loading map
console.log(this.myVar); //undefined
console.log(this);//jQuery promise
console.log(myFuncs.myVar); //true
}
return myFuncs;
});
execute:
require(['funcs'], function (myFuncs) {
myFuncs.init();
});
How to make this=myFuncs not jQuery promise??