jsp 页面 extjs3关于文本框 失去焦点事件

页面是jsP写了一个文本框输入
这个页面引入了js 是用extjs3写的
我现在想在js里面获取到这个文本框 然后监听这个文本框的 失去焦点事件
别说在当前jsp页面 直接写onblur事件
Ext.select("t").on('onblur',function(e){
alert(0);
});
我这样写 没反应

第1个回答  2014-02-17

extjs事件有简单写法

api给你

blur : ( Ext.form.Field this ) 

Fires when this field loses input focus.

Listeners will be called with the following arguments:

this : Ext.form.Field


使用方法也给你,写在

Ext.form.TextField的属性里面

listeners: {  
             'blur': function(f){  
                    alert('失去焦点!');  
                  }  
     }

追问

这个组件是在jsp里面写的 不用extjs里面定义的

追答

我明白了,你用

var myobject = Ext.get('object_id');

获取jsp页面里面的组件,然后再用on监听。

给你一份代码,刚给你调试的。


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--ӽɫҹʽτݾ-->
<link rel="stylesheet" type="text/css" href="../../ext/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="../../ext/ext-patch.css" />
<!--ӽɫ֗ӣȽ֯-->
<script src="../../ext/adapter/ext/ext-base.js"></script>
<!--ӽɫࠢτݾ-->
<script src="../../ext/ext-all.js"></script>
<script>
Ext.onReady(function(){
  Ext.get('equip_id').on('blur',function(f){  
                    alert('失去焦点');  
                  }  );
});
</script>
</head>
<body>
 <input type="text"  id="equip_id"  />
  <input type="text"  id="dd"  />
</body>
</html>

相似回答