响应事件:
1.设置一个html标记
<div id="my-div">Ext JS 4 Cookbook</div>
var el = Ext.get('my-div');el.on('click', function(e, target, options){
alert('The Element was clicked!');
alert(this.id);
}, this);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
});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
}
});var whatsNewEl = Ext.get('whats-new');
<span style="font-family: Arial, Helvetica, sans-serif;">whatsNewEl.on('click', function(e, target, options){
</span><span style="font-family: Arial, Helvetica, sans-serif;">alert(target.innerHTML);</span>}, this, {
delegate: 'li'
});Ext.Ajax.request({
url: 'url',params:{},//参数
success: function(response, options){
//成功获取数据后的处理
},
failure: function(response, options){
//失败
},
callback: function(options, success, response){
//回调函数
},
timeout: 60000 //60 seconds (default is 30)
});原文地址:http://blog.csdn.net/litdwg/article/details/37994565