PDA

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



luke83
8 Nov 2006, 12: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
8 Nov 2006, 5: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
8 Nov 2006, 6:40 AM
thanks jack.. now it works.. great :D

sentalus
19 Jun 2008, 6: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