javascript - How to access parent component ExtJS? -
for reason, blur event doesn't fired when below floating panel loses focus. however, when listen 'el' of panel blur event, gets registered shown in listeners config. want hide panel when blur event occurs. how access parent panel ?
ext.define('notekeeper.view.tabs.attachmentpanel',{ extend : 'ext.panel.panel', alias : 'widget.attachmentpanel', itemid : 'attachmentpanel', floating : true, focusable : true, width : 200, height : 150, layout : { type : 'vbox' }, items : [ { xtype : 'grid', store : null, columns : [ { text : 'file name', dataindex : 'filename' }, { dataindex : 'remove' } ] }, { xtype : 'button', text : '+' } ], listeners : { el: { blur: { fn: function() { console.log( ); //how access 'attachmentpanel' here //so can hide ? } } } }, noteid : null, initcomponent : function() { this.callparent(arguments); } });
please note there can multiple instances of these 'attachmentpanel's.
the following appears work fine:
listeners : { el: { blur: { fn: function() { console.log(this); var elid = this.id; var attachmentpanels = ext.componentquery.query('#attachmentpanel'); ext.array.foreach( attachmentpanels, function(cmp){ if(cmp.id == elid) { cmp.hide(); return false; } }); } } }
please let me know if there better/more efficient solution. thanks!
Comments
Post a Comment