ExtJS study NOTE 2: respond to events and load data using AJAX

Source: Internet
Author: User

ExtJS study NOTE 2: respond to events and load data using AJAX

RESPONSE event:

1. Set an html Tag

Ext JS 4 Cookbook

2. Use the get function to obtain the tag object

var el = Ext.get('my-div');

3. Bind the response function to the event of the object.

el.on('click', function(e, target, options){alert('The Element was clicked!');alert(this.id);}, this);

4. You can bind multiple events at a time.

el.on({click: function(e, target, options){alert('The Element was clicked!);alert(this.id);},contextmenu: function(e, target, options){alert('The Element was right-clicked!');alert(this.id);},scope: this});

5. You can also use listeners in configuration to configure attributes when creating an extjs object.

Ext.create('Ext.panel.Panel', {title: 'Ext JS 4 Cookbook',html: 'An Example Panel!',renderTo: Ext.getBody(),width: 500,listeners: {afterrender: function(){alert('The Panel is rendered!');},scope: this}});

6. You can also bind the Event Response to the sub-object through proxy.

var whatsNewEl = Ext.get('whats-new');whatsNewEl.on('click', function(e, target, options){alert(target.innerHTML);
}, this, {delegate: 'li'});

Load data using AJAX

Ext.Ajax.request({url: 'url',
Params :{}, // parameter success: function (response, options) {// processing after data is obtained successfully}, failure: function (response, options) {// Failed}, callback: function (options, success, response) {// callback function}, timeout: 60000 // 60 seconds (default is 30 )});


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.