EXT 3.x 자세히 설명된 Ext.History 브라우저의 앞뒤로 기능(1) 사용

먼저 예를 들자. 여기에 ext 공식적인 예를 쓰고 주석을 주의한다.
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/common/taglib.jsp"%>
//    ext   css js,        
<html>
	<head>
		<title>Ext3         </title>
		<script type="text/javascript">
		Ext.onReady(function() {
			
			//   history  
    		Ext.History.init();
    
			//     
		    var tokenDelimiter = ':';
		    
		    
		    var tp = new Ext.TabPanel({
		        renderTo: Ext.getBody(),
		        id: 'main-tabs',
		        height: 300,
		        width: 600,
		        activeTab: 0,//         
		        
		        items: [{
		            xtype: 'tabpanel',
		            title: 'Tab 1',
		            id: 'tab1',
		            activeTab: 0,//         
		            tabPosition: 'bottom',//   
		            
		            items: [{
		                title: 'Sub-tab 1',
		                id: 'subtab1'
		            },{
		                title: 'Sub-tab 2',
		                id: 'subtab2'
		            },{
		                title: 'Sub-tab 3',
		                id: 'subtab3'
		            }],
		            
		            listeners: {
		                'tabchange': function(tabPanel, tab){
		                	//tab1        hash
		                    Ext.History.add(tabPanel.id + tokenDelimiter + tab.id);
		                }
		            }
		        },{
		            title: 'Tab 2',
		            id: 'tab2'
		        },{
		            title: 'Tab 3',
		            id: 'tab3'
		        },{
		            title: 'Tab 4',
		            id: 'tab4'
		        },{
		            title: 'Tab 5',
		            id: 'tab5'
		        }],
		        
		        listeners: {
		            'tabchange': function(tabPanel, tab){
		            		//main-tabs        hash
		                    Ext.History.add(tabPanel.id + tokenDelimiter + tab.id);
		            }
		        }
		    });
		    
		    //     hash #      
		    Ext.History.on('change', function(token){
		        if(token){
		        //             
		            var parts = token.split(tokenDelimiter);
		            var tabPanel = Ext.getCmp(parts[0]);
		            var tabId = parts[1];
		            
		            tabPanel.show();
		            tabPanel.setActiveTab(tabId);
		        }else{
		        //                  
		            tp.setActiveTab(0);
		            tp.getItem(0).setActiveTab(0);
		        }
		    });
		});
		</script>
	</head>
	<body>
	<!-- Ext.History   form  begin-->
		<form id="history-form" class="x-hidden">  
             <input type="hidden" id="x-history-field" />  
             	<iframe id="x-history-frame">  
             </iframe>  
        </form> 
    <!-- Ext.History   form  end -->    
    
    
     <!--        -->	
      <input type="button" onclick="Ext.History.fireEvent('change',Ext.History.getToken());" value="  ">
      
     <!--         add    -->	 
      <input type="button" onclick="Ext.History.add('main-tabs:tab1');" value="   ">
      
      <!-- 
      	       ,   tabchange     Ext.History
      	     Ext.History       
                                 
       -->
	</body>
</html>

좋은 웹페이지 즐겨찾기