Reputation: 446
If you have a sencha FieldSet and has many fields, you can delegate an event to his sons:
fieldset.on({
change: 'ChangeFieldValue',
delegate: 'field',
scope: me
});
Also, I haven't find good documentation about delegate events. If anybody know about it please let me know.
Working with:
Sencha 6.0.2.14
Upvotes: 0
Views: 103
Reputation: 5020
A simple selector to filter the event target or look for a descendant of the target. The "delegate" option is only available on Ext.dom.Element instances (or when attaching a listener to a Ext.dom.Element via a Component using the element option). This is a configuration option that you can pass along when registering a handler for an event to assist with event delegation. By setting this configuration option to a simple selector, the target element will be filtered to look for a descendant of the target. See the delegate example below.
var panel = Ext.create({
xtype: 'panel',
renderTo: document.body,
title: 'Delegate Handler Example',
frame: true,
height: 220,
width: 220,
html: '<h1 class="myTitle">BODY TITLE</h1>Body content'
});
// The click handler will only be called when the click occurs on the
// delegate: h1.myTitle ("h1" tag with class "myTitle")
panel.on({
click: function (e) {
console.log(e.getTarget().innerHTML);
},
element: 'body',
delegate: 'h1.myTitle'
});
Upvotes: 1