javascriptjqueryurlmod-rewritejquery-ui-tabs

jquery ui tabs interfering with dynamic content using mod-rewrite


I have a problem with jquery ui tabs. I have a mod rewrite which rewrites; e.g:

link1 to link2

The problem is that I have a few jquery ui tabs which prevents the dynamic data from being loaded. I am guessing it's due to the #tabname that is added to the end of the pretty url like so:

link2 to link3

How can I get the dynamic data to be loaded in it's correct tab with or without the #tabname in the url.


Solution

  • My assumptions, based on your description: that this is only a problem when people go to that link with the hash tag directly, like from a bookmark or emailed link; and that you're parsing the url on the client side in order to dynamically load the data.

    At the top of your document.ready():

    $document.ready(function() {
       document.location.hash = "";
       ...
    

    This will remove the hash tag. If you needed to use it to go to the right tab, do:

    $document.ready(function() {
       var tabName = document.location.hash;
       document.location.hash = "";
       // use tabName here to reveal tab