button

method one:

Ext.onReady(function(){
Ext.create('Ext.Button', {
    text: "CLICK",
    renderTo: Ext.get("login")/getBody(), //设置显示区域
    scale   : 'large', //设置按钮大小
    handler: function() {
             var form = this.up('form').getForm();//获取表单对象
//var field=form.findField("cloudSubsriberId");//表单取值“id:'cloudSubsriberId'”
   //var value=field.getValue();
                form.submit({
                    clientValidation:true,//进行客户端验证
                  waitMsg:'Registering......',
                  waitTitle:'Registering',
                  url:'cloudUser!register.action',
                  method:'POST',
                  success:function(form,action){
                  if (action.result.success == '1') {
                          document.location='login.jsp';
                        }else{
                          document.location='register.jsp';
                        }
                  },
                  failure:function(form,action){
                     Ext.Msg.alert('Registering','Register fial');
                  }
                  });
    }
});
})



method two:


Ext.onReady(function(){
Ext.create('Ext.Button', {
    text    : 'Dynamic Handler Button',
    renderTo: Ext.get("login"),
    handler : function() {
        // this button will spit out a different number every time you click it.
        // so firstly we must check if that number is already set:
        if (this.clickCount) {
            // looks like the property is already set, so lets just add 1 to that number and alert the user
            this.clickCount++;
            alert('You have clicked the button "' + this.clickCount + '" times.\n\nTry clicking it again..');
        } else {
            // if the clickCount property is not set, we will set it and alert the user
            this.clickCount = 1;
            alert('You just clicked the button for the first time!\n\nTry pressing it again..');
        }
    }
});
})



method three:


Ext.onReady(function(){
Ext.create('Ext.Button', {
    text: "CLICK",
    renderTo: Ext.get("login"),
    scale   : 'large',
    enableToggle: true,
    arrowAlign: 'bottom',
    menu      : [
{text: 'Item 1'},
{text: 'Item 2'},
{text: 'Item 3'},
{text: 'Item 4'}
    ],
    handler: function() {
//alert('You clicked the button!')
    }
});
})





method foure:


Ext.onReady(function(){
Ext.create('Ext.Button', {
    text     : 'Button',
    renderTo : Ext.getBody(),
    listeners: {
        click: function() {
            // this == the button, as we are in the local scope
            this.setText('I was clicked!');
        },
        mouseover: function() {
            // set a new config which says we moused over, if not already set
            if (!this.mousedOver) {
                this.mousedOver = true;
                alert('You moused over a button!\n\nI wont do this again.');
            }
        }
    }
});
})

你可能感兴趣的:(button)