PDA

View Full Version : passing variables to other files



vipezz
24 Mar 2011, 9:44 AM
Hello,

i have a question, i'm looking to find an answer on how to pass variables from one file to another.

I have a store wich contains the following:


test.stores.groupStore = new Ext.data.JsonStore({
model:'Groups',
proxy:{
type:'ajax',
url: owt.config.groepStoreUrl,
reader: {
type: 'json',
root: 'items'
}
},
autoLoad:'true',
listeners : {
load : function(me) {
me.data.each(function(record) {
var groups = record.get('naam');
});
}
}
});

so i've created a variable "groups" to put the data in but i have no idea how i can access this variable in for example one of my view panels. Any idea on how to solve this?

tyvm

24 Mar 2011, 10:36 AM
You need to get out of the mindset of "files" in javascript for that perspective. Your question should be "How can i gain a reference to some component in the JavaScript namespace. The answer to that depends on how you have your application structured.

vipezz
24 Mar 2011, 10:45 AM
well this is my routepanel:


test.views.RoutePanel = Ext.extend(Ext.Panel, {
title: 'route',
fullscreen:true,
layout: 'card',
items: [

map = new Ext.Map({
useCurrentLocation: true,
listeners: {
delay: 500,
afterrender: function() {
var geo = new Ext.util.GeoLocation({
accuracy: 1,
autoUpdate: true,
listeners: {
locationupdate: function (geo) {
console.log(geo.latitude);
console.log(geo.longitude);
center = new google.maps.LatLng(geo.latitude, geo.longitude);

if (map.rendered)
map.update(center)
else
map.on('activate', map.onUpdate, map, {single: true, data: center});
},
locationerror: function (geo, bTimeout, bPermissionDenied, bLocationUnavailable, message) {
if (bTimeout) {
alert('Timeout occurred.');
}
else {
alert('Error occurred.');
}
}


}
});
calcRoute();
geo.updateLocation();
var marker = new google.maps.Marker({
position: defaultLocation,
map: this.map
});
directionsDisplay = new google.maps.DirectionsRenderer();
directionsDisplay.setMap(this.map);

}
}


}

)
]

});

Ext.reg('test-routepanel', test.views.RoutePanel);

I would like to put a loop around the part where i'm making a marker and use the variable inthere