jqPlot - How to programmatically find under which jQuery UI tab plot exists

前端 未结 1 1292
你的背包
你的背包 2021-01-16 05:39

Please take a look at the following example:

http://www.jqplot.com/deploy/dist/examples/hiddenPlotsInTabs.html

In the first example, the hidden graphs are pl

相关标签:
1条回答
  • 2021-01-16 06:30

    You have to approach it in the following way:

    1. Take the chart id you want to find from somewhere.
    2. Use jQuery to select the chart.
    3. Find its parent using parent() method --- this is the tab containing it.
    4. Use attr('id') of the parent to get its id.

    This is how I show it in jsfiddle sample available here.

    EDIT

    From what I understand you want to get the index of selected tab, which is effectively ui.index. Since I couldn't find a ready method in the jQuery UI, this is how I achieved it (this code is also added to the previous jsfiddle sample):

        var tabIndex = -1;
        $("#tabs ul li").each(function(index){
            if('#'+tabId === $(this).find("a").attr('href')){
                tabIndex = index;
                return false;
            }
        });
    
    0 讨论(0)
提交回复
热议问题