?
Solved

triggering a jquery ui tab from a link?

Posted on 2009-04-28
1
Medium Priority
?
775 Views
Last Modified: 2013-11-11
Hi There,

I'm trying to trigger a jquery tab click from a link outside the container. Can someone help me with this code please?

Sean
<!doctype html>
<html lang="en">
<head>
	<title>jQuery UI Tabs - Default functionality</title>
	
	<link type="text/css" href="/themes/base/ui.all.css" rel="stylesheet" />
	<script type="text/javascript" src="js/jquery-1.3.1.min.js"></script>
	<script type="text/javascript" src="ui/ui.core.js"></script>
	<script type="text/javascript" src="ui/ui.tabs.js"></script>
 <style type="text/css" media="screen">
    
 </style>
	<script type="text/javascript">
	$(function() {
		$("#tabs").tabs();
});
 
$(document).ready(function() {
    $("div#tbanavigation ul.tabNavigation li a").click(function(event) {
        var targetTab = $(this).get(0).id;
        console.log(targetTab.substring(1));
        $("div#thetabclass div#tabs ul li a").eq(targetTab).toggle();
        
 
        return false;
    });
 
});
	</script>
 
</head>
<body>
 
    
    <div id="tbanavigation">
            <ul class="tabNavigation">
		        <li><a id="t1" href="#bottom">Nunc tincidunt</a></li>
		        <li><a id="t2" href="#bottom">Proin dolor</a></li>
		        <li><a id="t3" href="#bottom">Aenean lacinia</a></li>
		        
	        </ul>
	</div>        
	        
<div id="thetabclass">
 
        <div id="tabs">
 
	        <ul>
		        <li><a href="#tabs-1">Nunc tincidunt</a></li>
		        <li><a href="#tabs-2">Proin dolor</a></li>
		        <li><a href="#tabs-3">Aenean lacinia</a></li>
	        </ul>
	        <div id="tabs-1">
 
		        <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>
		        
	        </div>
	        <div id="tabs-2">
		        <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.</p>
 
	        </div>
        	
	        <div id="tabs-3">
		        <p>Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec, luctus a, lacus.</p>
		       
	        </div>
        </div>
 
</div><!-- End demo -->
 
 
</body>
</html>

Open in new window

0
Comment
Question by:MrAgile
1 Comment
 
LVL 16

Accepted Solution

by:
anoyes earned 2000 total points
ID: 24264343
You can select a tab by calling

$('#tabs').tabs('select',index);

where index is the 0-based index of the tab you want to select.

Also, for future reference, there are a bunch of options available for tabs, and they can all be seen here:
http://www.jqueryui.com/demos/tabs/
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question