-
7 Feb 2013 3:32 AM #1
Answered: Newbie questions
Answered: Newbie questions
Hello,
Ext JS is something new for me. I hope someone answer my questions.
- What is the different between this.control and this.application.on within ths init:function inside a controller file?
- If I have different panels with buttons inside a viewport, how do you catch the events for the different button-pushes from the views inside the controller?
- If I have three different fields within same panel, how can I use the same change-listener for all the three fields?
-
Best Answer Posted by Arg0n
1.
this.application.on: listen to events fired by your application, it's mostly used for firing an event in a controller:
and listen to it on another controller, this will be replaced in ExtJs 4.2 there you can use this.control for it =)Code:this.application.fireEvent('blaaa');
this.control: can listen to nearly everything with the help of a selector
2.
The common way is to give the buttons an action:
then listen to it in the controller:Code://... Button config... bla action: 'user-create';
3.Code:this.control({ 'button[action=user-create]': { click: this.createUserAction } });
Just call the same function o.O
Code:Code:this.control({ 'textfield[itemId=user-email]': { change: this.changeWhatever }, 'textfield[itemId=user-name]': { change: this.changeWhatever }, 'textfield[itemId=user-passwd]': { change: this.changeWhatever }, });
-
7 Feb 2013 5:15 AM #2
1.
this.application.on: listen to events fired by your application, it's mostly used for firing an event in a controller:
and listen to it on another controller, this will be replaced in ExtJs 4.2 there you can use this.control for it =)Code:this.application.fireEvent('blaaa');
this.control: can listen to nearly everything with the help of a selector
2.
The common way is to give the buttons an action:
then listen to it in the controller:Code://... Button config... bla action: 'user-create';
3.Code:this.control({ 'button[action=user-create]': { click: this.createUserAction } });
Just call the same function o.O
Code:Code:this.control({ 'textfield[itemId=user-email]': { change: this.changeWhatever }, 'textfield[itemId=user-name]': { change: this.changeWhatever }, 'textfield[itemId=user-passwd]': { change: this.changeWhatever }, });
-
7 Feb 2013 5:57 AM #3
Thank you for your reply.
Should the listeners be programmed inside the views or be moved to the controllers if you follow the recommended MVC-architecture?
-
7 Feb 2013 6:18 AM #4
Listeners should be moved to the controllers if you want to use the MVC structure.
One big disadvantage is, that you cant listen to store events in controllers... You can, but it's tricky ^^
This will be changed with ExtJs 4.2 too =)
-
7 Feb 2013 6:21 AM #5
Great,
The last question?
Is it any difference to set up listeners for the view components in the controllers by using, itemId, name or action?


Reply With Quote