Twitter的引导标签]分页"方法的一些页面内容的ajax负荷后不工作 [英] Twitter bootstrap tabs "tab" method not working after ajax loading of some page content

查看:133
本文介绍了Twitter的引导标签]分页"方法的一些页面内容的ajax负荷后不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Twitter引导我的工作。在标签的方法 (即; $(标签)标签下利一元(秀))swiches由jQuery选择指定的完全新的选项卡,直到一个ajax加载已经完成了。当我创建使用 jQuery的追加一个新的标签,装载由 jQuery的负载其窗格中的内容,并尝试切换到新的使用标签标签(秀),它提供了可是没有一个方法设置页

I am using twitter bootstrap in my work. The "tab" method (ie; $("a element under tab li").tab("show") ) swiches to the new tab specified by the jQuery selector perfectly, until an ajax loading is done. When I create a new tab using jQuery append, load its pane content by jQuery load and try to switch to that new tab using tab("show") it gives error element doesnt have a method tab

更新

    <div class="tabbable">
      <ul class="nav nav-tabs" id="tab-set">
        <li class="active"><a data-toggle="tab" href="#tab1"> tab 1</a></li>
        <li><a data-toggle="tab" href="#tab2">tab 2</a></li>
        <li><a data-toggle="tab" href="#tab3">tab 3</a></li>
        <li><a data-toggle="tab" class="ajax" href="test.html">tab 4 - ajax</a></li>
      </ul>
      <div class="tab-content" id="tab-content">
        <div id="tab1" class="tab-pane active"> tab 1 content </div>
        <div id="tab2" class="tab-pane"> tab 2 content </div>
        <div id="tab3" class="tab-pane"> tab 3 content </div>
      </div>
    </div>

这是JavaScript code通过AJAX添加新的标签

This is the javascript code to add new tab via ajax

$("#tab-set").append("<li id='"+tabType+"'><a href='#" + tabType +
       "-pane' data-toggle=\"tab\"> " + tabName + "</a></li>");

$("#tab-content").append("<div class=\"tab-pane\" id=\"" +tabType + "-pane\"></div>");
$("#" + tabType + "-pane").load(tabUrl);

添加新的选项卡我尝试使用切换到该选项卡后,

After adding new tab i try to switched to that tab using

$("#" + tabType + " a").last().tab("show");

但是,这并不正常工作。

but that doesn't work.

推荐答案

是的,我有麻烦了。

我用 $(#+ tabType +-pane)负载(tabUrl)加载页面; 呐,该网页也有HTML,头部,body元素,它也是在它装载jQuery的。产生问题。它的一些相关的特定问题的<一个href="http://stackoverflow.com/questions/4787457/javascript-doesnt-execute-in-safari-when-loading-entire-page-via-jquerys-load">here

I was loading a page using $("#" + tabType + "-pane").load(tabUrl); na, that page also had html, head, body elements and it was also loading jquery in it. That created the problem. Its something related to the problem given here

现在我改变它加载只需要基本的内部元素加载页面的内容,没有标签,如HTML,头部,脚本,身体等。

Now i changed the contents of the loading pages that it loads only the basic inside elements needed, without tags like html, head, script, body etc.

这是给人头痛了整整一天对我来说。感谢上帝,我终于固定它。

This was giving headache for me a whole day. Thank god that i finally fixed it.

修改

甚至不需要移除所有元素。只需要(通过$加载(#+ tabType +-pane)负载(tabUrl)。)照顾不加载的jQuery的再次从加载页面。

Not even need to remove all elements. Just need to take care of not loading jquery again from that loading page (loading via $("#" + tabType + "-pane").load(tabUrl);).

这篇关于Twitter的引导标签]分页&QUOT;方法的一些页面内容的ajax负荷后不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆