从其他页面上的链接覆盖默认的 jQuery UI 选项卡
我正在我目前正在处理的网站的主页上使用 jQuery UI 选项卡 (v1.7x),它们的设置如下:
jQuery(document).ready(function($) {
$("#mastheadhome").tabs({
selected:4,
fx: {opacity: 'toggle'}
});
});
页面加载时一切正常,并且我想要的选项卡默认情况下显示的内容按应有的方式显示 - 但是,我想链接到网站上单独页面的其他一些选项卡,不用说我是否使用哈希链接(即“/#panel1”) ,上面代码中的“selected”属性会拦截它并覆盖所有内容!
我只是想知道是否有一种简单的方法可以在加载时在主页上显示默认选项卡(索引 4),但通过其他页面的链接选择不同的选项卡?
我期待听到任何人对此的想法!
亚历克斯
I am using jQuery UI tabs (v1.7x) on the home page of a site I'm working on at the moment, and they are set up as follows:
jQuery(document).ready(function($) {
$("#mastheadhome").tabs({
selected:4,
fx: {opacity: 'toggle'}
});
});
It's all working great when the page loads, and the tab I want to be displayed by default is displayed as it should be - however, I'd like to link to some of the other tabs from separate pages on the site, and needless to say if I use a hash link (i.e. "/#panel1"), the "selected" attribute in the above code intercepts it and overrides everything!
I was just wondering if there was an easy way to display the default tab (index 4) on the home page on load, but select different tabs via links from other pages?
I look forward to hearing anyone's thoughts on this!
Alex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
亚历克斯,
我修改了你上面写的内容,这样它就可以工作,而不必明确说明预期值(更灵活)。
在我的页面上工作正常。 :)
Alex,
I modified what you had written above so that it will work without having to explicitly state the expected values (more flexible).
Works alright on my pages. :)
感谢您关于查询字符串的建议 - 这促使我采用以下解决方案:
它不是非常优雅,但是嘿,它有效!
如果有人能想到更好的方法,我很想听听!
Thanks for the suggestion about querystrings - This prompted me to go for the following solution:
It's not hugely elegant, but hey, it works!
If anyone can think of a better way, I'd love to hear about it!
您可以向具有选项卡控件的页面添加查询字符串选项,然后将索引注入页面服务器端:)
You could add a querystring option to the page which has the tabs control, and then inject the index into the page serverside :)