PDA

View Full Version : Give variable from function to another.



myput
2 Nov 2011, 6:17 AM
Hello,

i have a problem with my application in general. I don't know how to send a variable from a function to another function.
Example:

I have a list, and a detailCard. In this detailcard, i have some button. Example button one, a map... In my list ItemTap function, i can call a function who is in the map file configuration by:


itemtap: function(view, index) {
var record = WPApp.stores.ResultPanelListStore.getAt(index);
WPApp.views.CarteButton.initMap(record.data);
WPApp.views.SearchPanel.setActiveItem(WPApp.views.ResultPanelDetail, {animation: {type:'slide', direction:'right'}});
}


And in the map Panel:



WPApp.views.CarteButton = Ext.extend(Ext.Panel,{
coords: [45.935, 6.632],
mapText: '',
permLink: '',
layout: 'fit',
initMap: function(data) {
this.pos = new google.maps.LatLng(data.latitude, data.longitude);
},
initComponent: function() {
var position = new google.maps.LatLng(this.coords[0], this.coords[1]);
this.dockedItems = [{
xtype: 'toolbar',
title: 'Location',
items: [
{
backText: ' ',
ui: 'plain',
iconMask: true,
useTitleAsBackText: false,
iconCls: 'arrow_left',
scope: this,
handler: function() {
WPApp.views.SearchPanel.setActiveItem(WPApp.views.ResultPanelDetail, {type:'slide', direction:'right'});
}
},
{
xtype: 'spacer', flex: 1
},
{
ui: 'plain',
iconCls: 'action',
iconMask: true,
scope: this,
handler: function(){
Ext.Msg.confirm('Lien Externe', 'Ouvrir dans Google Maps?', function(res) {
if (res == 'yes') window.location = this.permLink;
}, this);
}
}
]
}]
var infowindow = new google.maps.InfoWindow({
content: 'Bienvenue chez moi, la variable {name} ne marche pas'
});
this.map = new Ext.Map({
mapOptions : {
center : position,
zoom: 12,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.DEFAULT
}
},
listeners: {
maprender : function(comp, map){
var marker = new google.maps.Marker({
position: position,
title : 'titre',
map: map
});
infowindow.open(map, marker);
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
}
}
});
this.items = this.map;
WPApp.views.CarteButton .superclass.initComponent.call(this);
}
});




For the moment i have coords: [45.935, 6.632], but i would like to get my data in the function initMap who contain longitude and lattitude .... and pass this variable at the initialisation of the MAP.

But it's the same for all components ... I just would like pass variables from function to another ... And if i can to pass this function to initComponent .... But i don't know other way to init a map ...


Thanks

myput
4 Nov 2011, 8:38 AM
up