PDA

View Full Version : on activate works only first time - scope problem, i think


luke83
11-08-2006, 02:58 AM
ok in my page:

impellcment.net/chat

i have this function:


getRoom : function(id,rm){
if (getEl("room"+id)!=null){ // checking if just created the panel
// just created, let it show:
layout.getRegion('center').showPanel("room"+id)
}else{ // let create it and set the "activate" listner:

// creation code
[..]

// here an updater
[..]

rid=id; // this is a global var to set every time we are in a room :D

// so setting the activate function for the new panel
layout.getRegion('center').getPanel("room"+id).on("activate",App.setRoom(id),App,true);
}
}


the setRoom is simple function to set rid var:


setRoom : function(id){
rid=id;
alert(rid);
},


what is the problem?
when u click on the right link as "bar" or "piazza" it create the panel, insert it in the central region, change the rid and show u this rid.. so the set function is called.

But when u change panel and than return in the panel created nothing is show, rid is not setted and we have "s.fn has no proprieties" error :shock:

thx for time spent :roll:

jack.slocum
11-08-2006, 07:06 AM
http://www.jackslocum.com/forum/viewtopic.php?t=444

For binding a scope(App) and parameter(s) to a function, use createDelegate:

layout.getRegion('center').getPanel("room"+id).on("activate",App.setRoom.createDelegate(App, [id]));

luke83
11-08-2006, 08:40 AM
thanks jack.. now it works.. great :D

sentalus
06-19-2008, 09:17 PM
ok in my page:

impellcment.net/chat

i have this function:


getRoom : function(id,rm){
if (getEl("room"+id)!=null){ // checking if just created the panel
// just created, let it show:
layout.getRegion('center').showPanel("room"+id)
}else{ // let create it and set the "activate" listner:

// creation code
[..]

// here an updater
[..]

rid=id; // this is a global var to set every time we are in a room :D

// so setting the activate function for the new panel
layout.getRegion('center').getPanel("room"+id).on("activate",App.setRoom(id),App,true);
}
}


the setRoom is simple function to set rid var:


setRoom : function(id){
rid=id;
alert(rid);
},


what is the problem?
when u click on the right link as "bar" or "piazza" it create the panel, insert it in the central region, change the rid and show u this rid.. so the set function is called.

But when u change panel and than return in the panel created nothing is show, rid is not setted and we have "s.fn has no proprieties" error :shock:

thx for time spent :roll:

I tend to agree mostly, but I don't fully understand