EXT 3.x詳細なExt.Historyブラウザの前進後退機能を使用する(一)
4115 ワード
まず例を挙げましょう.ここに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>