PDA

View Full Version : Component Listeners - Delegating Single Event to Multiple Classes



kanghai@vintedge.com
31 Jul 2012, 8:49 PM
How do we go about delegating an event to multiple classes?

I've tried the following 2 methods and it doesn't work for me.

xtype: "container",
listeners: {
tap: {
fn: function(e) {
var el = e.target;
},
element: 'element',
delegate: '.classA, .classB',
scope: this
}
}

and



xtype: "container",
listeners: {
tap: {
fn: function(e) {
var el = e.target;
},
element: 'element',
delegate: ':(.classA|.classB)',
scope: this
}
}

mitchellsimoens
2 Aug 2012, 9:57 AM
Do you mean CSS classes or ST classes?

kanghai@vintedge.com
2 Aug 2012, 8:39 PM
CSS Style



xtype: "container",
html: "<div class='classA'>Click me</div><div class='classB'>Click me</div>"
listeners: {
tap: {
fn: function(e) {
var el = e.target;
},
element: 'element',
delegate: '.classA, .classB',
scope: this
}
}

kysna
6 Aug 2013, 12:31 AM
I am kind of wondering about the same thing.
How to delegate an event to multiple components. Is this possible in general?


(This code should scroll the page to a certain Y position, when a textfield is focused to prevent a keyboard on android from covering this textfield.)

listeners: [
{
event: 'focus',
fn: function(comp, e, eopts) {
var ost = comp.element.dom.offsetTop;
this.getScrollable().getScroller().scrollTo(0, ost);
},
delegate: [ '#id1', '#id2', '#id3' ] //how to do something like this
}
],
(Consider #idX to be an id of a textfield inside a fieldset.)