PDA

View Full Version : Strange behavior of Controller.control()



salomo
21 Nov 2011, 9:52 AM
In a Controller this code works:


init: function() {
this.control({
'contentview button[action=goBack]': {
click: this.handleButtonClick
},
'contentview button[action=goNext]': {
click: this.handleButtonClick
}
});
}

With contentview beeing a Panel with a Toolbar and 2 buttons.

The following code in another Controller fails for the second view. Only events for the first view work:


init: function() {
this.control({
'menutree': {itemclick: this.handleMenuClick}
},
{
'navigationtabs': {tabchange: this.handleTabChange}
});
}

In the example above, 'menu tree' works. When putting 'navigation tabs' before 'menutree', 'navigation tabs' works.

Both events work when I write the code like this:


init: function() {
this.control({
'menutree': {itemclick: this.handleMenuClick}
});
this.control({
'navigationtabs': {tabchange: this.handleTabChange}
});
}

Is there a restriction on not using different views within one Controller.control() call?

I'm using Ext JS 4.0.6

Thanks for your help.
Johannes

flanders
21 Nov 2011, 10:08 AM
You are opening and closing extra objects, which you shouldn't. Take a look at this:



init: function() {
this.control({
'menutree': {
event: handler,
anotherEvent: anotherHandler
},
'navigationtabs': {
event: handler
}
});


In your first and second example you are providing multiple arguments. Here I am not. One argument, but multiple properties

salomo
21 Nov 2011, 12:45 PM
Hello Flanders,

ok, I can see the problem now. Thank you so much for pointing things out.

Kind regards,
Johannes