In jquery-ui 1.9, how do you create new tabs dynamically?

前端 未结 5 1278
情话喂你
情话喂你 2020-12-13 14:51

According to the upgrade guide for jquery-ui 1.9 tabs - http://jqueryui.com/upgrade-guide/1.9/#deprecated-add-and-remove-methods-and-events-use-refresh-method - when adding

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-13 15:40

    An example is described in more details here moreover there is a runnable version is on jquery ui's official site with its source code.

    A simple declaration could be something like the following:

    var addTab = function (tabs, tabId, tabLabel, tabContentHtml) {
         var header = "
  • " + tabLabel + "
  • " tabs.find(".ui-tabs-nav").append(header); tabs.append("

    " + tabContentHtml + "

    "); tabs.tabs("refresh"); };

    Addition of a new tab is getting easier, just type the following:

    $("#tabs_area").tabs();
    addTab($("#tabs_area"), "tab_id1", "Tab 1", "this is just test");
    

提交回复
热议问题