ExtJs的Ext.Button的简单用法之事件

据我所知,Ext.Button 的事件注册方式有3中,如下例:

<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 11-2-11
  Time: 下午6:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>Simple jsp page</title>
    <link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css">
    <script type="text/javascript" src=\'#\'" /adapter/ext-base.js"></script>
    <script type="text/javascript" src=\'#\'" /ext-all.js"></script>
    <script type="text/javascript">

        Ext.onReady(
                   function(){
                       var _myBtn= new Ext.Button({
                           renderTo:Ext.getBody(),
                           text:"确&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;定",
                           minWidth:100,
                           height:40,
                           handler:function(){
                               alert("handler句柄属性方式注册的处理事件!");
                           },
                           //推荐使用的注册事件的方式
                           listeners:{
                               "click":function(){
                                   alert("listeners添加监听属性的方式注册的监听事件!");
                               }
                           }
                       });

                       //EXT传统写法
                       _myBtn.on("click",function(){
                           Ext.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
                               if (btn == 'ok'){
                                   alert("你点击了"+btn+"\n输入的信息是:"+text);
                               }else if(btn=='cancel'){
                                   alert("you chosen "+btn+"!");
                               }
                           });
                       });


                   }
                );
    </script>

</head>
<body>
</body>
</html>

本文出自 “Mr__Lee__Home” 博客,谢绝转载!

你可能感兴趣的:(职场,ExtJs,休闲)