PDA

View Full Version : How to update controller controlled objects after an object was dynamically loaded ?



Oldaf
23 Jan 2013, 3:41 AM
Hello,

I'm writing my first Sencha application.

In that application, I have to add panels (gridviews) dynamically to my card. They are built externally and loaded with ajax requests. I then use

newComponent = eval(<ajax answer>);
and then

myCard.add(newComponent);

It works fine.

Each of these dynamic objects will have its own xtype.

But, each one has to react specifically to a click on one of its list rows.

So, in each of these dynamic objects, in the "added" event, I call one function of the main application global UserInterface controller


mainUIController.AddControlledEvent("<my new panel xtype>, 'itemclick', this.ListRowClicked);

that means each dynamic object must have a ListRowClicked() function.

But, how to program the UI controller AddControlledEvent() function ?

I tried


AddControlledEvent(itemId, eventType, relatedFunction) {

this.control({
itemId: {
itemclick: relatedFunction // itemclick is hardcoded for the moment
}
});
}

but it doesn't work. Why ?

How to update controller controlled objects after a new object was dynamically loaded ?

Thanks for all

mitchellsimoens
28 Jan 2013, 1:27 PM
Why not use the control method on the controller when the component is loaded.

Oldaf
15 Feb 2013, 2:42 AM
Thanks, I will try it