Ext学习笔记(3):Button学习Demo

<html>
<head>
<!-- Ext按钮Demo -->
<script src="js/ext-all.js"></script>
<link href="css/ext-theme-gray-all.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
	Ext.onReady(function() {
		Ext.create('Ext.Button', {
			text : 'Click me',
			arrowAlign : 'right',/*menu显示的按钮位置(bottom/right)  */
			renderTo : Ext.DomQuery.selectNode("div[@id='as']"),
			handler : function() {/* 单击后的处理事件 */
				if (this.clickCount) {
					this.clickCount++;
					// alert('You have clicked the button "' + this.clickCount + '" times.\n\nTry clicking it again..');
				} else {
					this.clickCount = 1;
					// alert('You just clicked the button for the first time!\n\nTry pressing it again..');
				}
			},
			enableToggle : true,/*点击会改变按钮显示状态(类似于开关)  */
			menu : [/* 单击后展开的菜单 */
			{//按钮菜单
				text : 'Item 1',
				href : 'http://www.baidu.com',
				hrefTarget : '_blank'
			}, {
				text : 'Item 2'
			}, {
				text : 'Item 3'
			}, {
				text : 'Item 4'
			} ],
			listeners : {/*监听触发事件并处理  */
				click : function() {
					// this == the button
					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.');
					}
				}

			}
		});
		Ext.create('Ext.Button', {
			text : 'Load',
			renderTo : Ext.DomQuery.selectNode("div[@id='load']"),
			menu : [//类型菜单
			{
				xtype : 'textfield',
				fieldLabel : 'Foo'
			}, {
				xtype : 'textfield',
				fieldLabel : 'Bar'
			}, {
				xtype : 'numberfield',
				fieldLabel : 'Num'
			} ]
		});
		Ext.create('Ext.button.Cycle', {//循环菜单
			showText : true,
			prependText : 'View as ',
			renderTo :  Ext.DomQuery.selectNode("div[@id='Cycle']"),
			menu : {
				id : 'view-type-menu',
				items : [ {
					text : 'Java',
					iconCls : 'view-text',
					checked : true
				}, {
					text : 'C#',
					iconCls : 'view-html'
				}, {
					text : 'Object C',
					iconCls : 'view-html'
				}]
			},
			changeHandler : function(cycleBtn, activeItem) {
				Ext.Msg.alert('Change View', activeItem.text);
			}
		});
		
	});
</script>
</head>
<body>
	<div id="as" style="margin-left: 100px;"></div>
	<br>
	<div id="load" style="margin-left: 100px;"></div>
	<br>
	<div id="Cycle" style="margin-left: 100px;"></div>
	
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值