标准html中的事件处理
- <script> function a() { alert('some thing'); }</script><input id="btnAlert" type="button" onclick="a();" value="alert框" />
绑定的方式
- <script>function a(){alert('some thing');}window.onload=function(){document.getElementById("btnAlert").onclick=a;}</script><input id="btnAlert" type="button" value="alert框" />
==============================================================
EXT绑定事件
- <script>function a(){alert('some thing');}Ext.onReady(function(){ Ext.get("btnAlert").addListener("click",a); });</script><input id="btnAlert" type="button" value="alert框" />
EXT绑定多个事件
- Ext.onReady(function(){ Ext.get("btnAlert").on("click",a);Ext.get("btnAlert").on("click",a); });
EXT事件延迟处理
- Ext.onReady(function(){ Ext.get("btnAlert").on("click",a,this,{delay:2000}); });
在调用addListener的时候传递指定的delay为2000,因此当用户点击按钮的时候,不会马上执行事件响应函数,而是在2000毫秒,也就是两秒后才会弹出提示信息框。
事件弹出窗口
- <html>
- <head><title>Getting Started Example</title>
- <meta http-equiv="Content-Type" content="text/html;charset=gb2312">
- <link rel="stylesheet" type="text/css" media="all" href="extjs/resources/css/ext-all.css" />
- <script type="text/javascript" src="extjs/adapter/ext/ext-base.js"></script>
- <script type="text/javascript" src="extjs/ext-all.js"></script>
- <script type="text/javascript" language="javascript">
- var i=0;
- function newWin()
- {
- var win=new Ext.Window({title:"窗口"+i++,
- width:400,
- height:300,
- maximizable:true});
- win.show();
- }
- Ext.onReady(function(){
- Ext.get("btn").on("click",newWin);
- });
- </script>
- </head>
- <body>
- <div id="hello"></div>
- <input id="btn" type="button" name="add" value="新窗口" />
- </body>
- </html>