1.應用在textfield中的回車方式:
var siteName = new Ext.form.Field({
id: 'loadUrl',//表單元素最好使用Id,否則在IE瀏覽器中表單內容將變形
fieldLabel: '密碼',
listeners : {
specialkey : function(field, e) {
if (e.getKey() == Ext.EventObject.ENTER) {
alert("提交");
}
}
}
2.爲button的回車方式:
var map = new Ext.util.KeyMap({
target: "my-element",
key: 13, // or Ext.event.Event.ENTER
fn: function(){
alert("回車")
},
scope: myObject //做用域 他的父級Ext.getFly()
});
3.若是綁定其餘元件的話用原生綁定(我沒找到其餘辦法,有的話麻煩告訴我一下,例如給window彈窗綁定):
var window=new Ext.window.Window({
title: '另存',
height: 560,
width: 400,
id: 'newFileList',
layout: 'fit',
modal: true,
autoShow: true,
items:{
xtype:"treepanel",
id:'treePanel'
},
style: 'background-color:#233646;',
header: {
height: 22,
style: 'padding:1px 5px;'
},
listeners: {
afterRender: function () {
$("#treePanel").keyup(function (e) {
if (e.keyCode == 13) {
Ext.getCmp("saveConfirm").handler()
}
})
}
},
})