PDA

View Full Version : How to add listeners for Ext.History (MVC)



sannas
1 Jul 2012, 9:30 PM
Ext.define('MediaBank.controller.History', {
extend: 'Ext.app.Controller',

init: function () {
console.log('History controller init!');
this.control({
'history': { /* <What should be here
change: this.onChange
}

});

},

onChange: function (token) {
console.log('History controller onChange');
alert(token);
}
});

sword-it
1 Jul 2012, 11:40 PM
Hi sannas,

Try this......



Ext.define('MediaBank.controller.History', {
extend: 'Ext.app.Controller',
init: function () {
console.log('History controller init!');
this.control({
'#yourCmponentreference': {
change: this.onChange
} });
},
onChange: function (token) {
console.log('History controller onChange');
alert(token); }});

sannas
2 Jul 2012, 1:03 AM
Thank you sword-it!
Your code don`t work((

My code:
controller

Ext.define('MediaBank.controller.History', {
extend: 'Ext.app.Controller',

init: function () {
console.log('History controller init!');
this.control({
'history': {
change: this.onChange
}
});
},

onChange: function (token) {
console.log('History controller onChange');
alert(token);
}
});

view

Ext.define('MediaBank.view.History',
{
extend: 'Ext.Component',
alias: 'widget.history',
id: 'history',
html: '<form id="history-form" class="x-hide-display"><input type="hidden" id="x-history-field" /><iframe id="x-history-frame"></iframe></form>',

initComponent: function() {
console.log('init view History');
}
});