Details:
I am getting data for the html5 Geolocation; specifically longitude and latitude. I am trying to create a plugin that anyone can call from within a project and get the long and lat.
I have read this How to return response from an ajax call but I wondering how I should call these functions.
I placed a extjs tag even though I think it's more of a javascript core question
JavaScript:
Ext.define('Ext.ux.GeoLocation', {
alias: 'plugin.ux.geolocation',
constructor: function() {
console.log('called 1');
this.duh = 'yes';
this.init();
},
init: function () {
console.log('called 2');
navigator.geolocation.getCurrentPosition(this.test, this.test);
},
test: function(init) {
console.log('called 3');
this.duh = "amazing";
}
});
var geo = new Ext.ux.GeoLocation();
geo.test(); // this gets called twice though... incorrect?
The console out output is:
called 1
called 2
called 3
called 3
Is this a bad practice? Is there another solution?