This is a migrated thread and some comments may be shown as answers.

Making a tab active

1 Answer 203 Views
TabStrip (Mobile)
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 07 Aug 2012, 04:32 PM
I have a tabstrip that works for hash urls, but one of the tabs does a refresh but should stay on the same view.

<div data-role="tabstrip" id="tabstripMainApp">
   <a href="#viewJobs" data-icon="home">Current</a>
   <a href="#viewJobsCompleted" data-icon="more">Completed</a>
   <a href="#viewSettings" data-icon="about">Settings</a>
   <a class="btnRefreshView" data-icon="refresh">Refresh</a>
</div>

The said tab fires this event successfully:

$('.btnRefreshView').bind('click', function () {
console.log('Refresh view :', window.location.hash)
if (window.location.hash == '#viewJobsCompleted') {
dsviewJobsCompleted.read();
} else {
dsviewJobs.read();
}
})

But then the btnRefreshView tab shows as active when I want the prior tab that was active to be active.

How do I make a different tab active please?

1 Answer, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 1
answered on 23 Aug 2012, 10:35 AM
I resolved this using the following, where the '#btn...' ID's refer to the tabstrip <a> tags: 

if (window.location.hash == '#viewJobsCompleted') {
dsJobsCompleted.read();
$('#btnRefreshView').removeClass('km-state-active');
$('#btnViewJobsCompleted').addClass('km-state-active');
} else {
dsJobs.read();
$('#btnRefreshView').removeClass('km-state-active');
$('#btnViewJobs').addClass('km-state-active');
}
Tags
TabStrip (Mobile)
Asked by
Kevin
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 1
Share this question
or