`

Three ways to use button with event

阅读更多

There are three ways to use button with event. Following are three samples.

 

/**
 * The first way to use button with event: default event is "onclick".
 * 
 *
*/

<script type="text/javascript">

	Ext.onReady(function(){

		new Ext.Button([
			renderTo: Ext.getBody(),
			text: "Confirm",
			handler: function(){
				alert("Welcome to ExtJS world!");
			}
		
		]);
	});

</script>

 

 

/**
 * The second way to use button with event.
*/

<script type="text/javascript">

	Ext.onReady(function(){

		new Ext.Button([
			renderTo: Ext.getBody(),
			text: "Confirm",
			listeners: {
				"click": function(){
					alert("Welcome to ExtJS world!");
				}

			}
		
		]);
	});

</script>

 

 

/**
 * The third way to use button with event.
*/

<script type="text/javascript">

	Ext.onReady(function(){

		var _button = new Ext.Button([
			renderTo: Ext.getBody(),
			text: "Confirm"		
		]);

		_button.on("click", function(){
				         alert("Welcome to ExtJS world!");
			              });
	});

</script>

 

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics