jqPlot graphs in each jQuery Mobile navbar tab, one is good, two are blank

本秂侑毒 提交于 2019-12-06 15:05:01

When tab widget is created, only the first tab is visible and the rest are hidden. Therefore, it is not possible to access them when their dimensions are unknown.

Hence, your only option is to run jqPlot whenever a tab is activated by listening to tabsactivate event. When tabsactivate fires, it returns index of activate tab $(this).tabs("option", "active"). At that point, run jqPlot based on retrieved index.

$(document).on("pagecreate", function () {
    $("#tabs").tabs({
        activate: function (e) {
            var activeTab = $(this).tabs("option", "active");
            if (activeTab == 0) {
                plot1();
            }
            if (activeTab == 1) {
                plot2();
            }
            if (activeTab == 2) {
                plot3();
            }
        }
    });
}).one("pagecontainershow", plot1); /* run it once on first tab */

Demo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!