PDA

View Full Version : [CLOSED]Multiple delegates in the lisneters config doesn't work



uzver
29 Mar 2011, 4:38 AM
Code:


Ext.define('CustomPanel' {
extend: 'Ext.panel.Panel',
initComponent: function () {
var me = this;
config = {
tpl: new Ext.Template(
'<div class="x-panel-notification">',
'Notification! <a href="#" class="showMore">Show</a>',
'<a href="#" class="hideNotification">X</a>',
'</div>'
),
listeners: {
body: {
scope: me,
delegate: ['.showMore', '.hideNotification'],
click: me.onLinkClicked
}
}
};

Ext.apply(me, config);
me.callParent(arguments);
},
onLinkClicked: function (e) {
}

});

After create component and click on the 'Show' link js throw error:


Uncaught Error parsing selector, parsing failed at ",.hideNotification"

evant
29 Mar 2011, 4:43 AM
This isn't a bug, the docs say that the delegate should be a string.

uzver
29 Mar 2011, 4:43 AM
like this ".showItems .hideNotification" ?

mankz
29 Mar 2011, 4:54 AM
Quoting Animal:



Delegate allows you to pick up events from multiple elements (All of which match a DomQuery selector) with only one handler.

To listen for clicks from both classes of element as you describe, you’d have to use


listeners: {
body: {
click: handlerFn,
delegate: ‘:any(.class1|class2)’
}
}


Comma-separated selectors don’t work right now.

uzver
29 Mar 2011, 5:01 AM
it works! thanks!