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:
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.
The last step is to initialize the widget by adding the following script to the
html document:
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
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.
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.