JS.ExtJS.Custom Events in Ext JS

Ext JS allows us to define custom events in class using Ext.mixin.Observable mixin. Ext.mixin.Observable provides common interface for publishing events in Ext JS 5 & 6.

The following example demonstrates how you can publish an event using mixins whenever student name changes.

In the above example, we have included Ext.mixin.Observable mixin using mixins config so that we can use it. In the constructor, we call this.mixins.observable.constructor.call(this, config) which initialiazes the config. In the updateName() method, we fire custom event studentNameChanged using fireEvent() method with new value. We handle this event on newStudent instance where we register the handler using on() method.

Try it on https://fiddle.sencha.com/#fiddle/3l5

Every component in Ext JS includes number of events which we can handle it in ViewController or in the component itself. Learn about component event in the component section.

This entry was posted in Без рубрики. Bookmark the permalink.