1
我想从输入文本字段“workItemTextField”中获取文本值,但无法使用下面的代码触发按键事件。rallytextfield上的听众
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
_onWorkItemKeyPress: function() {
console.log('In _onWorkItemKeyPress');
console.log(this);
},
launch: function() {
this.add({
title: 'Time Entry',
width: 800,
padding: 10,
bodyPadding: 10,
renderTo: Ext.getBody(),
layout: {
type: 'vbox',
align: 'bottom'
},
items: [
{
xtype: 'rallytextfield',
itemId: 'workItemTextField',
fieldLabel: 'Work Item ID',
labelAlign: 'top',
listeners: {
scope: this,
keypress: this._onWorkItemKeyPress
}
}]
});
}
});
我能得到它的火与此更换听众:
listeners: {
keypress: {
element: 'el',
fn: this._onWorkItemKeyPress
}
}
但它不会返回我期望的那样。 “this”是textfield,但我无法调用getValue(),并且我期望传入的属性(从查看api)不是我期望的。第一个参数是事件,第二个不确定,第三个是html元素。
我正在使用apps/2.0rc3/sdk.js。我已经查看了我可以在网上找到的所有代码,看起来我正确地做了这件事,但肯定有一些我错过了。我做错了什么?
谢谢!这样可行!是的,我将在keypress的函数调用中检查ENTER,但无法通过任何键调用该函数。另外,我并不知道“specialkey”。这将工作我们的伟大。仍然困惑为什么“按键”听众不工作,但这至少让我通过了我的问题。再次感谢! – 2014-09-11 12:32:23