简体   繁体   English

使用jquery加载不会加载带有jQuery Tabs的页面上的功能

[英]Using jquery load does not load features on page with jQuery Tabs

Is this possible or am I totally off base: 这可能吗?还是我完全脱离了基地:

I have a ASPX User Control that is named UserInfo.ascx 我有一个名为UserInfo.ascx的ASPX用户控件

It has the following load method to load an AJAX page 它具有以下加载方法来加载AJAX页面

$("#qhcContent").load("infopage.aspx #userDisplay", function (response, status, xhr) {

        if (status == "error") {

            ///// Show Error Message

            $("#qhcThrobber").fadeOut(500, function () {
                $("#qhcContent").fadeIn(300);
            });

        }
        else {

            $("#qhcThrobber").fadeOut(500, function () {
                $("#qhcContent").fadeIn(300);
            });

        }



    });

Then I have the ASPX page that has two tabs (via jQuery UI Tabs) and this is called to create the the basic tabs. 然后,我有了具有两个选项卡的ASPX页面(通过jQuery UI选项卡),并调用该页面来创建基本选项卡。 I know it works if I just navigate to the page regularly, but not when I envoke the load method. 我知道,如果我只是定期导航到页面,那么它会起作用,但是当我调用load方法时却不会。

 $().ready(function () {



        $("#quickCheckTabs").tabs();


  });

But the tabs are never being created on the aspx page. 但是,永远不会在aspx页面上创建选项卡。 Is this because of the way that jquery.load() works ? 这是因为jquery.load()的工作方式吗?

Thanks alot. 非常感谢。

-Seth -塞思

the #quickCheckTabs isn't present when the dom is ready. dom准备就绪后, #quickCheckTabs不存在。 ie $().ready() The quickCheckTabs is only present after the load command has finished. $().ready() quickCheckTabs仅在加载命令完成后才存在。 So what you need to do is to add $("#quickCheckTabs").tabs(); 因此,您需要做的是添加$("#quickCheckTabs").tabs(); to the onComplete callback of the load() function. load()函数的onComplete回调。

In Other Words: 换一种说法:

$("#qhcContent").load("infopage.aspx #userDisplay", function (response, status, xhr) {

        if (status == "error") {

            ///// Show Error Message

            $("#qhcThrobber").fadeOut(500, function () {
                $("#qhcContent").fadeIn(300);
            });

        }
        else {

            $("#qhcThrobber").fadeOut(500, function () {
                $("#qhcContent").fadeIn(300);
            });
            $("#quickCheckTabs").tabs();    
        }



    });

Oh and by the way.. ready() methods present in the pages that you load through ajax calls will never be fired. 哦,顺便说一下,通过ajax调用加载的页面中存在的ready()方法将永远不会被触发。

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

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