PDA

View Full Version : fireEvent does not return parameter values ExtJs 4



parvinder18
26 Dec 2012, 6:17 AM
Hi,

I have two controllers, Say Controller-A and Controller B,

Controller-A...{

.....
....
handleSomething : function () {
var itemName = 'myitem';
controller.application.fireEvent('handleSomethingInB' , itemName);
}
............
.........
}


and in controller B i have


Controller-B...{

init : function (){
...................
.......................

var controller = this;
controller.application.on({
handleSomethingInB : handleB(itemName),
scope : this
});
},
.....
....
handleB: function (itemName) {
console.log(itemName);
}
............
.........
}



This function handleB in controller B is not printing parameter value. But it is printing [object Object].

Can somebody tell me why this is printing [object Object] and not the actuall value. And if this is the standard outcome then how can i get the actull value (actuall value that i have assigned in cotrller A).

TIA

mitchellsimoens
28 Dec 2012, 8:53 AM
Working for me:


Ext.define('Test.controller.Main', {
extend : 'Ext.app.Controller',

init : function(app) {
app.on({
scope : this,
myevent : this.onMyEvent
});
},

onMyEvent : function(foo) {
console.log(foo);
}
});

Ext.application({
name : 'Test',

controllers : ['Main'],

launch : function() {

this.fireEvent('myevent', 'bar');

}
});