Book Image

Ext JS Essentials

By : Stuart Ashworth , Andrew Duncan
Book Image

Ext JS Essentials

By: Stuart Ashworth , Andrew Duncan

Overview of this book

<p>Ext JS 5 is a heavyweight JavaScript framework used by millions to build rich and interactive web applications. Its numerous widgets and advanced data package make it especially well-suited for enterprise class software. The framework encourages the creation of good architectures and is extremely customizable.</p> <p>Ext JS Essentials is aimed at giving you a fast-track understanding of Ext JS. This book covers the most important aspects of the framework in a concise but comprehensive way, ensuring your success using its many features.</p> <p>Written around an example application, the book is packed with practical insights into how the framework works, architecting your applications, working with data, and the many widgets on offer.</p>
Table of Contents (17 chapters)
Ext JS Essentials
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Firing events


The Ext.mixin.Observable class also provides a way to fire events, whether these are framework events or custom events. The fireEvent method will fire any event we require and pass parameters for consumption by the handler function. The following example shows us how to fire a custom confirmed event, passing the choice parameter on the button, and binding it to an onConfirmed handler:

Ext.define('BizDash.view.main.MainController', {
  extend: 'Ext.app.ViewController',
  onConfirm: function (choice) {
    if (choice === 'yes') {
      var button = this.getView().getButton();
      button.fireEvent('confirmed', choice)
    }
  },
  onConfirmed: function(choice){
    console.log('The CONFIRMED event was fired');
  },
  init: function () {
    button.on({
      mouseover: 'onMouseOver',
      mouseout: 'onMouseOut',
      click: {
        fn: 'onClickButton',
        single: true
      },
      confirmed: 'onConfirmed',
      scope: this
    });
  }
});