Documentation

Getting Started

jqxTabs represents a jQuery Tabs widget. jqxTabs is breaking the content into multiple sections. You can populate it from 'LI' elements for the tab titles and 'DIV' elements for tab contents.
Every UI widget from jQWidgets toolkit needs its JavaScript files to be included in order to work properly.

The first step is to create html page and add links to the javascript files and css dependencies to your project. The jqxTabs widget requires the following files:

<head>
<link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
<script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxtabs.js"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-2FX5PV9DNT"></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'G-2FX5PV9DNT');</script></head>

The next step is to create a div element within the body of the html document and add 'UL' and 'LI' elements for the tabs and 'DIV' elements for the tabs content. The number of 'LI' elements must match to the number of 'DIV' elements.
<div id='jqxTabs'>
<ul style='margin-left: 20px;'>
<li>Tab 1</li>
<li>Tab 2</li>
<li>Tab 3</li>
<li>Tab 4</li>
<li>Tab 5</li>
</ul>
<div>
Content 1
</div>
<div>
Content 2
</div>
<div>
Content 3
</div>
<div>
Content 4
</div>
<div>
Content 5
</div>
</div>

The last step is to initialize the widget by adding the following script to the html document:
<script type="text/javascript">
$(document).ready(function () {
$('#jqxTabs').jqxTabs({ width: 550, height: 150 });
});
</script>

To call a function(method), you need to pass the method name and parameters(if any) in the jqxTabs’s constructor.
$("#jqxTabs").jqxTabs(‘select’, 1);
To get the result of a function(method) call, you need to pass the method name in the jqxTabs’s constructor and parameters(if any).
$("#jqxTabs").jqxTabs(‘getTitleAt’, 0 );
To set a property(option), you need to pass the property name and value(s) in the jqxTabs's constructor.
$("#jqxTabs").jqxTabs({ collapsible: true });
To get a property(option), you need to pass the property name to the jqxTabs's constructor.
var collapsible = $("#jqxTabs").jqxTabs('collapsible');
To bind to an event of a UI widget, you can use basic jQuery syntax. Let’s suppose that you want to get the selected item when the user clicks. The example code below demonstrates how to bind to the ‘select’ event of jqxTabs.
$('#jqxtabs').on('selected', function (event) {
var item = event.args.item;
var title = $('#jqxtabs').jqxTabs('getTitleAt', item);
alert(title);
});

Basic Sample

<!DOCTYPE html>
<html lang="en">
<head>
<title>jQuery Tabs Sample</title>
<link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
<script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxtabs.js"></script>
<script type="text/javascript">
$(document).ready(function () {
// create jqxtabs.
$('#jqxtabs').jqxTabs({ width: 550, height: 150 });
$('#jqxtabs').bind('selected', function (event) {
var item = event.args.item;
var title = $('#jqxtabs').jqxTabs('getTitleAt', item);
alert(title);
});
});
</script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-2FX5PV9DNT"></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'G-2FX5PV9DNT');</script></head>
<body class='default'>
<div id='jqxtabs'>
<ul style='margin-left: 20px;'>
<li>Tab 1</li>
<li>Tab 2</li>
<li>Tab 3</li>
<li>Tab 4</li>
<li>Tab 5</li>
</ul>
<div>
Content 1
</div>
<div>
Content 2
</div>
<div>
Content 3
</div>
<div>
Content 4
</div>
<div>
Content 5
</div>
</div>
</body>
</html>

The result of the above code is:

Using jqxTabs with other widgets

jqxTabs has a callback function which is called: 'initTabContent'. The 'initTabContent' is invoked when a tab is selected for the first time. Using this callback function, you can initialize any widget which is inside the jqxTabs widget. You can also use it to load your content on demand. The only parameter that the function has is the selected tab's index.
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
<script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxtabs.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxsplitter.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var initSplitter1 = function () {
$("#splitter1").jqxSplitter({ width: 700, height: 700, panels: [{ size: 200}] });
}
var initSplitter2 = function () {
$("#splitter2").jqxSplitter({ width: 700, height: 700, panels: [{ size: 300}] });
}
// init widgets.
var initWidgets = function (tab) {
switch (tab) {
case 0:
initSplitter1();
break;
case 1:
initSplitter2();
break;
}
}
$('#jqxTabs').jqxTabs({ width: 725, height: 760, initTabContent: initWidgets });
});
</script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-2FX5PV9DNT"></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'G-2FX5PV9DNT');</script></head>
<body class='default'>
<div id='jqxTabs'>
<ul>
<li style="margin-left: 30px;">Tab 1
</li>
<li>Tab 2
</li>
</ul>
<div style="margin: 10px; overflow: hidden;">
<div id="splitter1">
<div>
Panel 1
</div>
<div>
Panel 2
</div>
</div>
</div>
<div style="overflow: hidden;">
<div style="margin: 10px;" id="splitter2">
<div>
Panel 1
</div>
<div>
Panel 2
</div>
</div>
</div>
</div>
</body>
</html>

Load Tabs Content with Ajax

To load tabs content using Ajax, you can use the 'initTabContent' callback function in a combination with the jQuery's 'get' or 'ajax' functions.
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
<script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxtabs.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcheckbox.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var loadPage = function (url, tabIndex) {
$.get(url, function (data) {
// dynamically appends data returned from a server to a content element with ID equal to "content1"
// for the first tab, "content2" for the second tab or "content3" for the third tab.
$('#content' + tabIndex).html(data);
});
}
// Create jqxTabs.
$('#jqxTabs').jqxTabs({
width: 580, height: 200,
initTabContent:
function (tab) {
var pageIndex = tab + 1;
loadPage('pages/ajax' + pageIndex + '.htm', pageIndex);
}
});
});
</script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-2FX5PV9DNT"></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'G-2FX5PV9DNT');</script></head>
<body class='default'>
<div id='jqxTabs'>
<ul>
<li style="margin-left: 30px;">Node.js</li>
<li>JavaServer Pages</li>
<li>Active Server Pages</li>
</ul>
<div id="content1">
Loading...
</div>
<div id="content2">
Loading...
</div>
<div id="content3">
Loading...
</div>
</div>
</body>
</html>