Log in

View Full Version : Need some help with Ajax Tabs Content Script (v 2.2)



romanticyao
04-16-2008, 11:13 PM
1) Script Title: Ajax Tabs Content Script (v 2.2)

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

3) Describe problem:

I have my Ajax Tabs Content Script setup and it works great, but I am having trouble with Dynamically selecting a tab using a remote link

I am using the ajax tab content with Vbulletin, same one used here, lol. on index.php, I've put tabbed content inside forumhome template, using the following code:


<div id="forumhome_header">
<div class="shadetabs">
<ul id="forumtabs">
<if condition="$show[member]"><li class="myfourm"><a class="seleted" href="/myforum.php?page=forumhome" rel="forumajax">tab0</a></li></if>
<li class="citycenter"><a href="/tabs/tab_hot1.php" rel="forumajax" rev="tcontent1">tab1</a></li>
<li class="youth"><a href="/tabs/tab_hot5.php" rel="forumajax" rev="tcontent2">tab2</a></li>
<li class="lifestyle"><a href="/tabs/tab_hot6.php" rel="forumajax" rev="tcontent3">生活小叙</a></li>
<li class="ent"><a href="/tabs/tab_hot2.php" rel="forumajax" rev="tcontent4">tab3</a></li>
<li class="univer"><a href="/tabs/tab_hot3.php" rel="forumajax" rev="tcontent5">tab4</a></li>
<li class="gen"><a href="/tabs/tab_hot4.php" rel="forumajax" rev="tcontent6">tab5</a></li>
<br class="clearfloat" />
</ul>
</div><br class="clearfloat" />
</div>


<div id="forumajax" class="forumajax"></div>


<script type="text/javascript">
var forumhome_forumtab=new ddajaxtabs("forumtabs", "forumajax")
forumhome_forumtab.setpersist(true)
forumhome_forumtab.setselectedClassTarget("link") //"link" or "linkparent"
forumhome_forumtab.init()
</script>


Then from a different page (forumdisplay.php) I want to use a remote link to go back to the index.php and have one of the tab to be selected. However, that didn't work...

Based on my setup, what should I do to make things work?

Thank you in advance for you help.:)

thetestingsite
04-16-2008, 11:22 PM
If you look at this page:

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

you could use the expandit function to expand based on what is passed in the url. Not sure how you would implement in vb, but just an idea to get you moving in the right direction.

Hope this helps.

romanticyao
04-16-2008, 11:31 PM
thanx for your reply!

Based on my setup, I wrote my remote link like this :
<a href="/bbs.php?forumtabs=2">Go to Forumhome and open up tab2</a>

however, it doesn't work.

note I renamed index.php to bbs.php

thetestingsite
04-16-2008, 11:37 PM
If you are doing that, then you will need to find a way to be able to get that data (the get variable for forumtabs) and pass that along to the expandit function in the script. Normally it would be something like this:



ajaxtabs_instance.expandit(<?php echo $_GET['forumtabs'];?>);


Although, being that this is vb and you are not able to parse php in your templates, I'm at a loss.
Hope this helps nonetheless.

romanticyao
04-16-2008, 11:45 PM
If you are doing that, then you will need to find a way to be able to get that data (the get variable for forumtabs) and pass that along to the expandit function in the script. Normally it would be something like this:



ajaxtabs_instance.expandit(<?php echo $_GET['forumtabs'];?>);


Although, being that this is vb and you are not able to parse php in your templates, I'm at a loss.
Hope this helps nonetheless.

Ok, I can define something like $tabid in vb's core php file which is bbs.php and have that passed to template forumhome, so I could put something like



ajaxtabs_instance.expandit($tabid);


in my forumhome template

That shouldn't be hard.

The question is, where should I put above code on my page...???

thetestingsite
04-16-2008, 11:48 PM
it would go just beneath the instance.init() function.

Hope this helps.

romanticyao
04-16-2008, 11:48 PM
I am guessing I should put the code inside


<script type="text/javascript">
var forumhome_forumtab=new ddajaxtabs("forumtabs", "forumajax")
forumhome_forumtab.setpersist(true)
forumhome_forumtab.setselectedClassTarget("link") //"link" or "linkparent"
forumhome_forumtab.init()
</script>

so I have somethin look like


<script type="text/javascript">
var forumhome_forumtab=new ddajaxtabs("forumtabs", "forumajax")
forumhome_forumtab.setpersist(true)
forumhome_forumtab.setselectedClassTarget("link") //"link" or "linkparent"
forumhome_forumtab.init()
forumhome_forumtab.expandit($tabid)
</script>

am I right?

thetestingsite
04-16-2008, 11:49 PM
That is correct.

romanticyao
04-16-2008, 11:49 PM
Great, I will give it a try and let you know if it works :)

Thank you for taking ur time here

romanticyao
04-16-2008, 11:55 PM
That works, thanx!

This thread might be helpful for other vb users