jquery-archive / jquery-mobile

jQuery Mobile Framework
https://jquerymobile.com
Other
9.68k stars 2.4k forks source link

tabs doesn't set "ui-btn-active" on <a> when setting "active" tab #8629

Open pstanton opened 6 years ago

pstanton commented 6 years ago

load the official docs tabs demo and then execute this code:

$("#tabs").tabs({"active": 2});

result: the tab content changes, but the selected tab is not decorated.

however, jqueryUI it works as expected

pstanton commented 6 years ago

workaround:

$("#tabs").on("tabsactivate", function(event, ui) {
    ui.newTab.find("a").addClass("ui-state-active ui-btn-active");
    ui.oldTab.find("a").removeClass("ui-state-active ui-btn-active");
});
pstanton commented 6 years ago

also, this needs to be set initially so that the default tab is decorated.

If the "create" event has already occurred, you can use

$("#tabs").tabs("instance").active.find("a").addClass("ui-state-active ui-btn-active");