简体   繁体   English

标签中的jQuery UI Tabs问题加载链接

[英]jQuery UI Tabs problem loading link in tab

I have a problem with jQuery UI tabs. jQuery UI选项卡有问题。 In details, I have tabs which are loading with ajax and my problem is that i want to load page links inside page but i cannot make it. 详细地讲,我有一些用ajax加载的选项卡,我的问题是我想在页面内加载页面链接,但我做不到。

This is the code of my page with the tabs: 这是带有标签的页面代码:

<script>
$(function() {


$( "#tabs" ).tabs({
    ajaxOptions: {
        error: function( xhr, status, index, anchor ){
            $(anchor.hash).html(
                "Could not load this tab");
        }
    }

});


});
</script>

<div id="tabs">
<ul>
<li><a href="#tabs-1">Welcome</a></li>
<li><a href="customer.php">Customers</a></li>
<li><a href="subscribers.php">Subscribers</a></li>
<li><a href="subscription.php">Subscriptions</a></li>
    </ul>

</div>

Let's assume know that i have load the tab subscriptions. 让我们假设我已经加载了选项卡订阅。 The subscription.php has a link to another page which i want to load in the same tab. subscription.php具有指向另一个页面的链接,我想在同一选项卡中加载该页面。

How can i make it work? 我该如何运作?

There are probably quite a few ways to do this, but here's a simple one. 可能有很多方法可以做到这一点,但这是一个简单的方法。

Give your link an id, say "link". 给您的链接一个ID,说“链接”。 Set a click handler to do a .load on a page to the desired div. 设置点击处理程序以在页面上执行.load到所需的div。 So: 所以:

 <a href="#" id="link">

<script type="text/javascript">
     $('#link').click(function() {
          $('#tabid').load('linkpage.html');
     });
</script>

Now, some clarification. 现在,进行一些澄清。 You'd have to have an id on the div of the tab you wanted to load content into....I called it tabid for illustration purposes. 要在其中将内容加载到的标签的div上必须有一个ID。...出于说明目的,我将其称为tabid。 The load takes the contents of the page, linkpage.html and sets it to be the new value of the div tabid. 加载将获取页面内容linkpage.html并将其设置为div Tabid的新值。 Basically, you're doing an inner html with external content. 基本上,您正在做带有外部内容的内部html。

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

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