当前位置: 代码迷 >> Web前端 >> Ext事件示范(Ext.Msg.alert)
  详细解决方案

Ext事件示范(Ext.Msg.alert)

热度:335   发布时间:2012-11-04 10:42:41.0
Ext事件示例(Ext.Msg.alert)
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   	<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css" />
	<script type="text/javascript" src="extjs/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="extjs/ext-all.js"></script>
	<script type="text/javascript" src="extjs/ext-all-debug.js"></script>
	<script type="text/javascript">
		Ext.onReady(function(){
		
		
		
			Person = function(name){
				this.name=name;
				this.addEvents("walk","eat","sleep");
			}
			Ext.extend(Person,Ext.util.Observable,{
				info:function(event){
					return this.name+'is'+event+'ing.';
				}
			});
		
		
			Ext.get('walk').on('click',function(){
					person.fireEvent('walk');
				});
				
			Ext.get('eat').on('click',function(){
				person.fireEvent('eat','早餐','中餐','晚餐');
			});
				
			Ext.get('sleep').on('click',function(){
				person.fireEvent('sleep',new Date());
			});
		
		
			var person=new Person('Lingo');
			person.on('walk',function(){
				Ext.Msg.alert('event',person.name+"在走啊走啊。");
			});
			person.on('eat',function(breakfast,lunch,supper){
				Ext.Msg.alert('event',person.name+"要吃"+breakfast+","+lunch+"和"+supper+"。");
			});
			person.on('sleep',function(time){
				Ext.Msg.alert('event',person.name+"从"+time.format("H")+"开始睡觉了。");
			});
			
			
			
			
			
			
			
		});
	</script>
  </head>
  
  <body> 
  <input type="button" value="walk" name="button1" id="walk">
  <input type="button" value="eat" name="button2" id="eat">
  <input type="button" value="sleep" name="button3" id="sleep"> 
  </body>
</html>

?

  相关解决方案