O'Reilly logo

Learning Ext JS - Fourth Edition by Armando Gonzalez, Crysfel Villa, Carlos A. Méndez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Triggers

In Ext JS version 5, the Trigger field was deprecated, and now triggers are set inside text fields. So now, we can add one or many triggers to a single field.

In order to work with triggers, let's write the following code:

var myTriggers = Ext.create( 'Ext.form.field.Text' , {
  fieldLabel: 'My Field with triggers',
  triggers: {
    searchtext: {
      cls: 'x-form-search-trigger',
      handler: function() {
        Ext.Msg.alert('Alert', 'Trigger search was clicked');
        this.setValue('searching text...');
      }
    },
    cleartext: {
      cls: 'x-form-clear-trigger',
      handler: function() {
        Ext.Msg.alert('Alert', 'Trigger clear was clicked');
        this.setValue('');
      }
    }
  }
});
newItems.push( myTriggers );

First, we created an instance of the Ext.form.field.Text class, and set ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required