jquery-archive / jquery-mobile

jQuery Mobile Framework
https://jquerymobile.com
Other
9.7k stars 2.41k forks source link

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

Open pstanton opened 5 years ago

pstanton commented 5 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 5 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 5 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");