JQuery的标签()方法的问题,创建标签 [英] JQuery tabs() method issue, tab creation

查看:114
本文介绍了JQuery的标签()方法的问题,创建标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出与jQuery一个错误,当我试图为我的ASP.Net应用程序创建的选项卡(我在JQuery的新手)。

I am trying to figure out an error with JQuery when I tried to create tabs for my ASP.Net application(I am a novice in JQuery)..

下面是code我想,当我试图用Chorme Dev.tool发现错误没有这样的方法添加制表符小部件实例调试,我发现tabsDiv.tabs(增加, '#main',页[I] [0]);这是增加的方法是从JQuery的新版本pcated德$ P $不工作了。
谁能帮我找到办法克服这个??

Below is the code I am trying, when I tried debugging using Chorme Dev.tool found error"no such method 'add' for tabs widget instance" and I found out "tabsDiv.tabs("add", '#main', pages[i][0]);" this does not work anymore as the "add" method is deprecated from the newer version of JQuery. Could anyone help me to find way to overcome this??

<script type="text/javascript">

    $(document).ready(function () {

        var pages = [
            ['Events', "/Listings.aspx", "/AddEvent.aspx", "UpdateOrDelete.aspx"],
            ['Performance', "/Performance.aspx"]
        ];

        var myPage = '<%=Request.Path %>';

        var tabsDiv = $('#masterTabsDiv');

    tabsDiv.tabs({
        select: function (event, ui) {
            document.location = pages[ui.index][1];
            return false;
        }
    });
    var indexToSelect = 0;

    for (var i = 0; i < pages.length; i++) {
        for (j = 0; j < pages[i].length; j++) {
            if (pages[i][j] == myPage) {
                indexToSelect = i;
                window.alert("set block 2");
                break;
            }
        }
        tabsDiv.tabs("add", '#main', pages[i][0]);
    }
    window.alert("set block 4");
    tabsDiv.find('li').removeClass('ui-tabs-selected ui-state-active');
    tabsDiv.find('li').eq(indexToSelect).addClass('ui-tabs-selected ui-state-active');
});
</script>

谢谢,
距空空导弹

Thanks, Raam

推荐答案

由于jQuery UI的1.10,你需要一个新的元素添加到DOM,然后调用 .tabs(刷新),所以你的code会像

Since jQuery UI 1.10 you need to add a new li element to the DOM and then call .tabs("refresh"), so your code will be something like

var tabsDiv = ('#masterTabsDiv');
tabsDiv.find('ul').append("<li><a href='#newTab'>New Tab</a></li>");
tabsDiv.append("<div id='newTab'>New content</div>");
tabsDiv.tabs("refresh");

这篇关于JQuery的标签()方法的问题,创建标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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