简体   繁体   English

jQueryUI选项卡-通过POST变量强制单击选项卡

[英]jQueryUI Tabs - force click on tab via POST variable

I wish to be able to open page on a specific tab by sending a message via GET variable. 我希望能够通过GET变量发送消息来打开特定选项卡上的页面。 I was thinking something like: 我在想类似的东西:

http://mydomain/mytimecards.php?tab=vte

Here is the code for the jQuery tabs: 这是jQuery标签的代码:

<div id="tabs">
    <ul>
        <li><a href="#mytimecards">Submit Time Cards</a></li>
        <li><a href="#timecardReports" id="vte">View Time Entries</a></li>
    </ul>
    <div id="mytimecards">
    etc ....

Is it possible to force the page to display the 2nd tab (#timecardReports) instead of the first ONLY IF ?tab=vte is received as a GET (or better yet POST) variable? 是否可以强制页面显示第二个选项卡(#timecardReports)而不是仅显示第一个选项卡?tab = vte是作为GET(或更好的是POST)变量接收的?

Assuming the plugin you are using allows you to set an active tab on load, you could do something like: 假设您使用的插件允许您在加载时设置活动标签,则可以执行以下操作:

<li><a href="#timecardReports" id="vte" <? if(isset($_GET['tab']) && $_GET['tab'] == 'vte'){ echo 'class="active"'; } ?>>View Time Entries</a></li>

Replacing class="active" with whatever the plugin requires you to set. 用插件需要您设置的内容替换class="active"

Thanks, guys, Ben and itachi were onto the right solution. 谢谢大家,Ben和Itachi提出了正确的解决方案。 This worked: 这工作:

http://mydomain.com/mytimecards.php?tab=vte#timecardReports

I found this by using firebug and watching what changed as the tabs were clicked. 我通过使用Firebug并观察了单击选项卡后发生的变化发现了这一点。 Thanks itachi. 谢谢itachi。

Ben's suggestion enabled me to test for this condition and set it on page load. Ben的建议使我能够测试这种情况并在页面加载时进行设置。

Credit to them both. 归功于他们俩。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM