I have an application which generates dynamic tabs using CFlayout. Each tab is composed of a combination of variables, but for the purposes of this post, it's not necessary to go into that.
Here's what's interesting. In the past, I've always gotten an error if CFlayout can't find the tab. If I change what the tab name is (knowing it will be incorrect) Coldfusion throws an error, so I know the tab exists normally, but for whatever reason, it's not switching.
Below is my code:
JavaScript
var uniqueTopTabID = someVar,
uniqueLowerTabID = uniqueTopTabID + someVar,
$topLayoutID = $('#cf_layoutarea' + uniqueTopTabID), //jquery objects to find if the tabs exist
$lowerTabID = $('#cf_layoutarea' + uniqueLowerTabID); //same as above
Here is the logic to either create a new tab, or select a previously created tab:
if ( $topLayoutID.length < 1 ) {
ColdFusion.Layout.createTab('innerTabLayout', uniqueTopTabID, 'tabName' , cfLayoutLocation, {inithide: false, selected: true, closable: true});
}
//if the subsystem and WBS have already been selected, focus on that tab
else if ( $lowerTabID.length !== 0 ) {
ColdFusion.Layout.selectTab( uniqueTopTabID, uniqueLowerTabID );
//i have also tried to select the top tab, and then select the bottom tab but that doesn't work either
}
And like I said, there is no error thrown--I can see that the focus comes off of the current parent tab, but for whatever reason, it doesn't select the other top level tab. If however the tab that is trying to be created is under the current parent tab, it will select the lower level tab.
Here is how I am generating the tabs on the ColdFusion side:
<cfif structKeyExists(URL,"bp")> <!--- make sure some var is available --->
<cfset actualsScenarioView = "actualsScenarioView"&URL.ss>
<cflayout name="#actualsScenarioView#" type="tab">
<cfset scenarioName = URL.tabId>
<cfset tabTitle = URL.subSystemName & ': ' & URL.wbsName>
<cfset sourceFile = 'the URL passed in' >
<cflayoutarea name="#scenarioName#" title="#tabTitle#" source="#sourceFile#" refreshOnActivate="false" closable="true">
</cflayoutarea>
</cflayout>
<cfelse>
<!--- if vars not avail, the page was request prior to submission, and will show noting--->
</cfif>
The tabs get created fine, and everything works except selecting a different parent tab.
Any help is greatly appreciated.
Almost all of the display aspects of ColdFusion are terrible. ColdFusion is a great middle-ware but it is not good at writing JavaScript whether it is form validation or divs.
You should seriously consider re-writing without cflayout take a look at http://static.raymondcamden.com/cfuitherightway/cflayout-tabs/index.html it is a blog by Raymond Camden & Adam Cameron that does overviews on how to better approach the things that ColdFusion ISN'T good at. It is a great resource.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With