JQuery tabs, use as a menu, load the page when you click on the link

I have added jQuery tabs to my site which is at a high level. There are no problems so far.

But I want - when I click on the tab - what it should do and behave like a regular link.

Exampel 1: Look at this link http://jqueryui.com/demos/tabs/default.html . By clicking on the options:

  • Nunc tincidunt
  • Proin dolor
  • Aenean lacinia

It loads the contents from the same file, and the URL is static (default.html).

I need the following:

Exampel 2: by clicking on

  • Nunc tincidunt (e.g. nunc.php)
  • Proin dolor (e.g. proin.php)
  • Aenean lacinia (e.g. aenean.php)

, . "Nunc tincidunt", nunc.php( URL- ), "Proin dolor" proin.php ..

?

+3
4

href , :

<div id="tabs"> 
    <ul> 
        <li><a href="nunc.php">Nunc tincidunt</a></li> 
        <li><a href="proin.php">Proin dolor</a></li> 
        <li><a href="aenean.php">Aenean lacinia</a></li> 
    </ul>
</div>​​​​​​​​​​

AJAX . , window.location select , :

$("#tabs").tabs({
    select: function(event, ui) {
       window.location = $.data(ui.tab, 'href.tabs');
    }
});​​​​​​​

( , /404 , PHP jsfiddle)

+3

, , / , :

[...]... URL- ajax

, , . , usablity (http://www.useit.com/alertbox/tabs.html).

$('#example').tabs({
    select: function(event, ui) {
        var url = $.data(ui.tab, 'load.tabs');
        if( url ) {
            location.href = url;
            return false;
        }
        return true;
    } });

. http://jqueryui.com/demos/tabs/#...follow_a_tab.27s_URL_instead_of_loading_its_content_via_ajax

0
source

Undoubtedly, is it a matter of replacing your links (#) with your .php links and changing the link identifier so as not to link to tab links?

0
source

Source: https://habr.com/ru/post/1757818/


All Articles