I want to control back button to set active tabs

My App using Tabbar to set the active view. the tabbar contains home page, catalogue, and setting. I want to set the active tab and active view to home page when press mobile back button if current active tab and active view is catalogue or setting.

If you use Cordova, you can add backbutton as event listener. You can check current active tab with .tab-link-active class as well.

I have add backbutton event listener. The problem is I don’t know how to set the active tab. because the backbutton handler writed in cordova-app.js. So, how to get the current active tab?

If your HTML look like this

<div class="toolbar tabbar tabbar-scrollable toolbar-bottom">
    <div class="toolbar-inner">
        <a href="#tab-1" class="tab-link tab-link-active">Tab 1</a>
        <a href="#tab-2" class="tab-link">Tab 2</a>
        <a href="#tab-3" class="tab-link">Tab 3</a>
        <a href="#tab-12" class="tab-link">Tab 12</a>

You can get current active tab with


Thanks, Problem solved. I can change the active tab now.:sunglasses: