简体   繁体   English

jQuery标签,为每个标签重新加载页面

[英]jquery tabs, reload page for each tab

Using jQuery ui tabs, is there an effective way to reload the page for each tab? 使用jQuery ui标签,是否有有效的方法为每个标签重新加载页面?

I tried doing 我试着做

$('#tab_two').click(function() {
    window.location = 'http://localhost/page#tab_two';
    });

But, that still lands on the current page. 但是,那仍然落在当前页面上。 However, if you refresh the page after that then it will redirect to #tab_two. 但是,如果之后刷新页面,则它将重定向到#tab_two。

The only way to effectively redirect the page seems to be using PHP. 有效重定向页面的唯一方法似乎是使用PHP。 But having 但是有

$('#tab_two').click(function() {
    header('location: http://localhost/page#tab_two');
    });

messes up the page. 弄乱了页面。

Any ideas on how to achieve this? 关于如何实现这一目标的任何想法? Thanks. 谢谢。

I think that you can use load method like I did below: 我认为您可以像下面一样使用load方法:

$(function() {
   $( "#tabs" ).tabs();

   $( "#tab_two" ).click(function() {
      $( "#tabs" ).tabs( "load" , 1 );   // zero-based (tab#1 = 0 index)
   });
});

Documentation: 说明文件:

.tabs( "load" , index ) Reload the content of an Ajax tab programmatically. .tabs(“ load”,index)以编程方式重新加载Ajax选项卡的内容。 This method always loads the tab content from the remote location, even if cache is set to true. 即使将cache设置为true,此方法也始终从远程位置加载选项卡内容。 The second argument is the zero-based index of the tab to be reloaded. 第二个参数是要重新加载的选项卡的从零开始的索引。

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

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