In the code below I need to render the view only after I have got valuea from a call on the Gmaps navigator. Until I have Latitude amd Longitude I can't render the view. Followinag some answers here I'm stuck with the error
Object [object global] has no method 'afterRender Thanks for any suggestion.
initialize: function() {
$.when(this.beforeRender).then(function(){
this.afterRender();
});
},
beforeRender: function () {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(this.onSuccessUpdatePos,
this.onFailUpdatePos);
} else {navigator.geolocation.getCurrentPosition(this.onSuccessUpdatePos,
this.onFailUpdatePos);
}
},
afterRender: function () {
this.render();
},
UPDATE: I did as I was told, and it seems that the sequence BeforeRender-> render-> afterRender is respected. I also added all of the initialization logic within the function Initialize(). the problem is that putting the functions in the sequence appears not to ensure the fact that the function render() is launched once acquired results.
I also tried it with
$.when(this.beforeRender).then(that.render);
as was suggested to me but still keeps giving me errors. It seems that beforeRender isn't launched. The error that keep showing me is
Uncaught SyntaxError: Unexpected token u
I think that happen because of sessionStorage & localStorage and these are not filled before the render function is launched. is there an effective way to wait for these results to be returned?