views:

301

answers:

2

in the below code none of the alerts are getting called?

<head>
<script src='../../Scripts/jquery/jquery.js' type='text/javascript'></script>
<link rel="stylesheet" href="../../content/jquery-tabs/jquery.tabs.css" type="text/css" media="print, projection, screen">
<script src="../../Scripts/jquery-tabs/jquery.history_remote.pack.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-tabs/jquery.tabs.min.js" type="text/javascript"></script>

<script type="text/javascript">
    $(document).ready(function() {
        $("#tabs").tabs();
    });

    $(document).ready(function() {
        $('#tabs').bind('tabsselect', function(event, ui) {

            // Objects available in the function context:
            alert(ui.tab);     // anchor element of the selected (clicked) tab
            alert(ui.panel);   // element, that contains the selected/clicked tab contents
            alert(ui.index);   // zero-based index of the selected (clicked) tab
        });
    });


</script> 

</head>
<body>

<h2>
    TestTabs</h2>
<div id="tabs">
    <ul>
        <li><a href="#fragment-1"><span>1 Info</span></a></li>
        <li><a href="#fragment-2"><span>2 Info</span></a></li>
        <li><a href="#fragment-3"><span>3 Info</span></a></li>
        <li><a href="#fragment-4"><span>4 Info</span></a></li>
    </ul>
    <div id="fragment-1">
        <h2>TestTabs</h2>
    </div>
    <div id="fragment-2">
        <h2>TestTabs</h2>
    </div>
    <div id="fragment-3">
        <h2>TestTabs</h2>
    </div>
    <div id="fragment-4">
        <h2>TestTabs</h2>
    </div>
</div>

+2  A: 

It works for me.

Make sure that you're using the current version of jQuery UI.

Do you get any script errors?

SLaks
how would i know if i get a script error. also, i tried debugging through firebug but i never get the callback. do i need jquery-ui.js as well as jquery.tabs.js. i thought that jquery.tabs.js was all that was needed
ooo
No, you need both `jquery-ui.js` and your tabs file, but you should really use the compressed bundle the site creates for you which wraps both into one file.
Doug Neiner
basically started from scratch as Doug mentioned as well as somehow it s working now . . think it was due to the missing jquery-ui files
ooo
actually, i see an issue with your example, i dont see #fragment- after you click on each tab.. do you know why this disappeared ??
ooo
+2  A: 

The code looks correct, which means most likely it is one of two things:

  1. Another JS error on the page
  2. You have not correctly included the UI library + tabs

My guess is #2, so you should double check that it is working. For kicks, go back to the http://jqueryui.com/download page, click "deselect all components" and then click on "Tabs" to select only core and tabs. Then choose "no theme" then download. Use that js file in place of your tabs.min.js file and see if it works then.

Last thing to check, make sure the version of jQuery + jQuery UI you are using match. For jQuery 1.3+, use jQuery UI 1.7.2. For jQuery 1.2.6, use jQuery UI 1.6

Doug Neiner