最近有用到Ext.form.textarea,在监听事件中添加了keyup事件,并将enableKeEvents属性设为true, 5
但是并没有执行该事件,不知道是什么原因?我的代码如下:Ext.onReady(function(){varform=newExt.form.FormPanel({base...
但是并没有执行该事件,不知道是什么原因?我的代码如下:
Ext.onReady(function() {
var form = new Ext.form.FormPanel({
baseCls: ‘x-plain’,
layout:’absolute’,
url:’save-form.php’,
defaultType: ‘textfield’,
items: [{
x: 0,
y: 5,
xtype:'label',
text: 'Send To:' },{
x: 60,
y: 0,
name: 'to',
anchor:'100%' // anchor width by percentage
},{
x: 0,
y: 35,
xtype:'label',
text: 'Subject:'
},{
x: 60,
y: 30,
enableKeyEvents: true,
name: 'subject',
anchor: '100%', // anchor width by percentage
listeners: {
keyup: function(src, evt){
alert(src.getValue()); }
}
},{
x:0,
y: 60,
xtype: 'textarea',
name: 'msg',
enableKeyEvents: true,
anchor: '100% 100%', // anchor width and height,
listeners: {
keyup: function(src, evt){
alert(src.getValue()); } } }] });
var window = new Ext.Window({
title: ‘Resize Me’,
width: 500,
height:300,
minWidth: 300,
minHeight: 200,
layout: ‘fit’,
plain:true,
bodyStyle:’padding:5px;’,
buttonAlign:’center’,
items: form, buttons: [{
text: 'Send' },{
text: 'Cancel' }] });
window.show(); });是我的代码出问题了? 展开
Ext.onReady(function() {
var form = new Ext.form.FormPanel({
baseCls: ‘x-plain’,
layout:’absolute’,
url:’save-form.php’,
defaultType: ‘textfield’,
items: [{
x: 0,
y: 5,
xtype:'label',
text: 'Send To:' },{
x: 60,
y: 0,
name: 'to',
anchor:'100%' // anchor width by percentage
},{
x: 0,
y: 35,
xtype:'label',
text: 'Subject:'
},{
x: 60,
y: 30,
enableKeyEvents: true,
name: 'subject',
anchor: '100%', // anchor width by percentage
listeners: {
keyup: function(src, evt){
alert(src.getValue()); }
}
},{
x:0,
y: 60,
xtype: 'textarea',
name: 'msg',
enableKeyEvents: true,
anchor: '100% 100%', // anchor width and height,
listeners: {
keyup: function(src, evt){
alert(src.getValue()); } } }] });
var window = new Ext.Window({
title: ‘Resize Me’,
width: 500,
height:300,
minWidth: 300,
minHeight: 200,
layout: ‘fit’,
plain:true,
bodyStyle:’padding:5px;’,
buttonAlign:’center’,
items: form, buttons: [{
text: 'Send' },{
text: 'Cancel' }] });
window.show(); });是我的代码出问题了? 展开
2个回答
展开全部
因为textarea的构造函数是一个完整的可独立的对象。所以你要更改下你上面的代码,如下面:
textarea.js
JScript code
Ext.onReady(function(){
var p = new Ext.Panel
title: ‘My Panel’,
collapsible:true,
renderTo: ‘tt’,
width:400,
height: 300,
items:[ {
x: 100,
y: 0,
xtype: 'textarea',
name: 'msg',
enableKeyEvents: true,
height:'100%',
width:'100%',
listeners: {
keyup: function(src, evt){
alert(src.getValue()); } } } ] }); });
js代码要去我空间看下,有点多呀!
textarea.js
JScript code
Ext.onReady(function(){
var p = new Ext.Panel
title: ‘My Panel’,
collapsible:true,
renderTo: ‘tt’,
width:400,
height: 300,
items:[ {
x: 100,
y: 0,
xtype: 'textarea',
name: 'msg',
enableKeyEvents: true,
height:'100%',
width:'100%',
listeners: {
keyup: function(src, evt){
alert(src.getValue()); } } } ] }); });
js代码要去我空间看下,有点多呀!
参考资料: http://www.znjcx.com
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询