ITeye博客

Three ways to use button with event

bluestorm · 2009-10-08 23:27 · ExtJS · Markdown

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)

暂无评论。

评论功能维护中,当前仅展示历史评论。