PDA

View Full Version : Define class and listeners and redefine listeners



madhu.vistex
3 Dec 2013, 11:56 PM
I have written code like this


Ext.define('Ext.ux.CustomTrigger', {
extend: 'Ext.form.field.Trigger',
xtype: 'customtrigger',
baseCls: 'srchTriggerBox',
initComponent: function () {
var me = this;




me.triggerCls = 'x-form-clear-trigger'; // native ExtJS class & icon




me.callParent(arguments);
},
onTriggerClick: function () {
this.setValue('');
this.fireEvent('keyup');
},
listeners: {
'keyup': function () {
console.log(this);
if (this.value == '') {
this.triggerEl.hide();
} else {
this.triggerEl.show();




}
},
'render': function () {
this.triggerEl.hide();
}
}
});

after that when i'm going to create object for this user may write his own code for keyup listener and render at that both functions should perform for that what is the solution

Gary Schlosberg
6 Dec 2013, 1:04 PM
Can you please clarify what you are trying to do here? It would help to post the code you've tried so far, perhaps in a Fiddle (https://fiddle.sencha.com/#home).

madhu.vistex
9 Dec 2013, 10:53 PM
Ext.define('Ext.ux.CustomTrigger', {
extend: 'Ext.form.field.Trigger',
xtype: 'customtrigger',
baseCls: 'srchTriggerBox',
initComponent: function () {
var me = this;
me.listeners = {
'keyup': function () {
if (this.value == '') {
this.triggerEl.hide();
} else {
this.triggerEl.show();
}
},
'render': function () {
this.triggerEl.hide();
}
}
me.triggerCls = 'x-form-clear-trigger';
me.callParent(arguments);
},
onTriggerClick: function () {
this.setValue('');
this.fireEvent('keyup');
},
});

the problem is solved now can write the keyup function again with out effecting this keyup function which is written in inside the initComponent