Hello fellow developers!
I have a question that is burning me since some days.
I have this controller, let say called: mainmap.js that among other things, shows a map and some annotations loaded from a REST webservice. Each time you click on an annotation, some data is loaded in a view that show on top of map. Between callbacks and eventlisteners, I have this properties that area defined inside the controller file, and used in some methods.
var _curCoord = { lat : null, lon : null }; var _curProp = { idprop : null };Called inside an eventlistener to store data
if(evt.clicksource == 'pin'){ topView.animate( { bottom:10, duration:500 }); topviewopen = true; // carga la informacion de la propiedad _curProp.idprop = evt.annotation.titleid; Ti.API.info('idprop set ' + _curProp.idprop); loadPropData(evt.annotation.titleid); loadPropImages(evt.annotation.titleid); }then I have to use the data stored to save stuff on the webservice or refresh data
if(_curProp.idprop == 'undefined') return; Ti.API.info('toggle fav ' + _curProp.idprop); if(!favico.favorite) { // marcar la propiedad como favorita properties.toggleFavoritoUsuario(_curProp.idprop,0,{ success: function(data) { var prop = data[0]; Ti.API.info(prop); favico.backgroundImage = 'favorite_icosel30.png'; favico.favorite = true; } }); }Then thing is that some times
_curProp.idprop has data, and randomly, other times just is undefined.
How would you solve this kind of situation?
Thanks for any advice :D