Dec 20, 2008, 3:00 PM
Issues with dynamic IDs and tab panels
I have the following Javascript code to open a new tab in a TabPanel when a node on a TreePanel is selected:
However it works fine when I have the following:
Note that I am using ASP.NET MVC and have the latest code committed to the SVN repository. Any help would be greatly appreciated.
<script type="text/javascript">
//<![CDATA[
var addTab = function(tabPanel, id, name, icon, url) {
var tab = tabPanel.getComponent(id);
if (!tab) {
tab = tabPanel.add({
id: id,
title: name,
closable: true,
border: false,
iconCls: icon,
autoLoad: {
showMask: true,
scripts: true,
mode: 'merge',
url: url,
maskMsg: 'Loading ' + name + '...'
}
});
}
tabPanel.setActiveTab(tab);
}
//]]
</script>
The following code returns javascript errors:<ext:TreeNode NodeID="ExampleNode" Text="Example" Icon="House" Expanded="true">
<Listeners>
<Click Handler='addTab(#{CenterTabPanel}, "ExampleTab", "Example", "icon-house", "/Example");' />
</Listeners>
<Nodes>
when my tab panel is coded as follows:<ext:TabPanel ID="CenterTabPanel" EnableTabScroll="true" runat="server">
</ext:TabPanel>
However it works fine when I have the following:
<ext:TreeNode NodeID="ExampleNode" Text="Example" Icon="House" Expanded="true">
<Listeners>
<Click Handler='addTab(CenterTabPanel, "ExampleTab", "Example", "icon-house", "/Example");' />
</Listeners>
<Nodes>
<ext:TabPanel ID="CenterTabPanel" IDMode="Static" EnableTabScroll="true" runat="server">
</ext:TabPanel>
(had to set the IDMode to static)Note that I am using ASP.NET MVC and have the latest code committed to the SVN repository. Any help would be greatly appreciated.