【发布时间】:2011-12-21 11:18:24
【问题描述】:
我正在尝试了解以下场景中的范围。在调用searchTerms时,scope:this下的this指的是searchTerms函数而不是面板本身。这似乎与我从其他示例中观察到的不同。我可以知道我犯了什么错误吗?
function searchTerms(){
var searchGrid = new Ext.grid.GridPanel({
});
var searchPanel = new Ext.form.FormPanel({
region: 'south',
height:150,
items:[
{
xtype: 'textfield',
fieldLabel: 'Keywords',
},{
xtype: 'textfield',
fieldLabel: 'Label',
},{
xtype: 'datefield',
fieldLabel: 'Valid till'
},new Ext.Button({
text: 'crawl',
scope: this,
handler: function(b,e){
Ext.Ajax.request({^M
url: '/discovery/tsearch',^M
params: {^M
keywords: this.items[0].getValue(),
label: this.items[1].getValue(),
valid: this.items[2].getValue(),
},
});
}
}),],
});
var regionPanel = new Ext.Panel({
title: 'search',
layout: 'border',
items: [searchPanel, searchGrid]
});
return regionPanel;
}
【问题讨论】:
标签: javascript extjs extjs3