PDA

View Full Version : Tab Content Problem



matt blank
09-28-2007, 09:37 AM
1) Script Title:
Tab Content Script

2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex17/tabcontent.htm

3) Describe problem:
I've installed the script and it works fine bar every now and then when you go on to the page and all the content is in one long list rather than hidden behind the tabs. This disappears if you refresh the page, and if you return to the page later it will probably be ok...

Any ideas why this may be happening?
Thanks!
Matt

matt blank
10-04-2007, 09:40 AM
Hi everyone,

It's been nearly a week since I posted this problem, and I've still got it!

Can anyone help me please?

Many thanks,
Matt

jc_gmk
10-04-2007, 10:02 AM
Try this version instead, i'm using it with no problems!
it uses ajax, so calls the content from an external page.

http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/index.htm

Also if you've got dynamic content you can use each of the tabs to send a query so you should only need one external page.

matt blank
10-04-2007, 10:09 AM
That's a good idea, however I have 20 pages that use tabs, with three tabs on each page. To use the AJAX version would mean creating a lot of unnecessary pages to create the content, instead of just 20 pages.

Therefore I would really like to just fix the tab content script if possible.

Thanks though!
Matt

ddadmin
10-04-2007, 10:16 AM
I've installed the script and it works fine bar every now and then when you go on to the page and all the content is in one long list rather than hidden behind the tabs. This disappears if you refresh the page, and if you return to the page later it will probably be ok...


There's no bug in the script itself that can cause this sort of instability- either it always works, or it doesn't. The two possible culprits are:

1) The CSS associated with this script (tabcontent.css) isn't always loaded properly when the page first loads for some reason. It is this CSS file that hides the tabs contents initially.

2) The call to initalize the script (initializetabcontent) isn't always called when the page first loads. The only reason this might happen is if you have some other JavaScript on the page that's throwing errors every once in a while. When it does, the browser halts all other JavaScripts from being called, indirectly affecting this script as well.

If you're still having problems, a link to the problem page might be helpful.

jc_gmk
10-04-2007, 10:20 AM
If you use php you could create just one external page for every single tab on your website!
I do the same.
For the tab link you would have something like


<a href="externalpage.php?content=whatever&id=1">TAB 1</a>

Then on the external page you would use the query (content=whatever and id=1) to call the content from a database (e.g. MySQL).

matt blank
10-04-2007, 11:12 AM
Thanks guys,

DD Admin, I've PM'd you with a link to the website, as I can't make it public just yet.

I've put all the CSS associated with the tabs into my main CSS, rather than as a separate file.

Your help would be appreciated!

Many thanks,
Matt

ddadmin
10-04-2007, 11:29 AM
l've checked your page. The css for ".tabcontent" needs the following in red:




.tabcontent{margin-top: 35px; display:none}

matt blank
10-04-2007, 12:33 PM
Excellent!! Thank you so much.

One last thing. Say I'm on my second tab and then I go to another page which also has the tabs on, ableit different content, how comes it starts on the second tab, rather than going back to the first one like it should?

Thanks!
Matt

ddadmin
10-04-2007, 08:19 PM
If you have persistence turned on (it's on by default inside the .js file), plus the two Tab Content scripts on the two pages both use the same ID for the UL element of the Tabs, then the script thinks the two are the same, with one Tab's persisted state transferring over to the other.

If you don't wish this to happen, give the Tab Content script on the other page a different ID.

matt blank
10-06-2007, 08:08 AM
Brill! Many thanks, the script is now perfect! :)

Matt