tags:

views:

384

answers:

2

This post talks about the problem that jQuery tabs is still having with the back button. What the customer needs is fairly simple - when they press back, they want to go back to what they were just looking at. But jQuery tabs loads the first tab, not the one that was selected when the user left the page.

I've read the accompanying link and it says "It is planned and Klaus is working on it whenever he finds the time."

Has anyone solved the back button problem with jQuery UI tabs?

+3  A: 

Have you tired updating the browsers location as you switch tabs? http://www.zachstronaut.com/posts/2009/06/08/jquery-ui-tabs-fix.html

easement
+1  A: 

Using the solution to the history problem easement posted, a dirty fix for the back button problem would be to periodically check the location.hash to see if it has changed, and if it has, fire the click event of the appropriate link.

For example, using the zachstronaut.com updated jQuery Tabs Demo, you could add this to the $(document).ready callback, and it would effectively enable the back button to switch tabs, with no more than a 500ms delay:

j_last_known_hash = location.hash;
window.setInterval(function() {
    if(j_last_known_hash != location.hash) {
        $('#tabs ul li a[href="'+ location.hash +'"]').click();
        j_last_known_hash = location.hash;
    }
}, 500);
Atli
Genius!This worked!
cf_PhillipSenn