jQuery (mb)Tabset 1.8

keep your tabs ordered!
A useful component that let you build a tabbed interface really easily; ad you can even sort your tabs as you want!
http://www.open-lab.com/mb.ideas/index.html#mbTabset
download page:
http://mbideasproject.googlecode.com/files/jquery.mbTabset.1.9.zip
jQuery project page:
http://plugins.jquery.com/project/mbTabset
Releases:
1.8 (New!)
minor bugfix:
Now the Ajax content is call just if the tab is the one visible or if you click on it.
1.7
Major bugfix:
- Fixed a bug that prevent to send ajaxData with the ajax call option.
1.6
Major issues:
- added the possibility to choose the startup tab :
if you need to start with a different tab than the first just add a “sel” class to the a attrubute of your tab:
class=”tab sel {content:’cont_1_2′}”
1.5
Major issues:
- added the possibility to load ajax content.
You now can pass other two params:- ajaxContent, containing the url of your ajax page
- ajaxData, containing the params to pass
- even if your tab content is called via ajax you have to specify the “content” param with the ID, needed to build the container for the ajax conent
I had to chang the html code to simplify the tabset constructor:
- the param called “container” now is “content“
- now it’s not anymore needed the wrapper div of each tabset contents with class “mbTabsetContainer”
- the tab contents can be written everywhere in the page
1.0
first release.
Dependencies:
ui.core.js
ui.sortable.js
optional:
jquery.metadata.js
How does it works:
here is the js call:
1 2 3 4 5 6 | $("#tabset1").buildMbTabset({ sortable:true, position:"left", start:function(){}, stop:function(){} }); |
here is the code for each tabset:
1 2 3 | <div class="tabset" id="tabset1"> <a id="a" class="tab {content:'cont_1'}">tab 1</a> <a id="b" class="tab { |
1 | content |
1 2 | :'cont_2', ajaxContent:'yourAjaxPage.jsp', ajaxData:'a=1&b=2&...'}" >tab 2 con testo lungo</a> <a id="c" class="tab disabled { |
1 | content |
1 2 | :'cont_3'}">tab 3</a> <a id="d" class="tab { |
1 | content |
1 2 | :'cont_4'}" >tab 4</a> </div> |
here is the code for each tabContent:
1 2 3 4 5 6 7 8 | <div style="padding:10px" id="cont_1"> <h3>container 2</h3> </div> <div style="padding:10px" id="cont_2"> <h3>container 2</h3> </div> <div style="padding:10px" id="cont_3"> <h3>container 3</h3></div> <div style="padding:10px" id="cont_4"> <h3>container 4</h3></div> |
Params
- sortable: (boolean) define if the tabs are sortable or not
- position: (“left” or “right”) define the tabset position
- start: (function) a callBack function on start sort
- stop: (function) a callBack function on stop sort
- to set a tab disable just add “disabled” to the tab class
- to load tab content via ajax just add: class=”tab sel {content:’cont_1_2′, ajaxContent:’your ajax page url’, ajaxData: ‘data you want to send’}”
to store the new position of the tabs there’s a variable
1 | $.mbTabset.mbTabsetArray |
that returns an array with new tab position each time a sortable action is completed; this variable is cross tabset so the best is to store on stop event via ajax. You can also use the UI method via:
1 | $(<strong>your tabset id</strong>).sortable("toArray") |
or
1 | $(<strong>your tabset id</strong>).sortable("serialize"). |
You can also switch a tabset between sortable or not by invoking:
1 | $( |
1 | <strong>your tabset id</strong> |
1 | <strong> </strong>).setSortableMbTabset() |
to set sortable
or
1 | $( |
1 | <strong>your tabset id</strong> |
1 | ).clearSortableMbTabset(); |
to destroy sortable




Hi ,
I have s:file upload tag in my jsp.and one sx:autocompleter tag.
if i change the element in sx:autocompleter the ajax to work.
But the s:file tag is preventing not to work ajax properly.
Can you give me some idea.Pls…..
Im trying this for past one week…..
Thanks in advance.
Hi Swathi,
can’t understand what do you mean…
do you have a public page where to see the issue?
Bye,
Matteo
If you disable sorting, so the tabs do not be sorted – do you need to have ui.sortable.js as part of the jscript includes? Since I do not want sort, I am wondering if I can make the jscript more compact by not including it.
Thanks,
Kenneth
First can I add to the congratulations! Looks great and really easy to get something up and running. I have two small issues which I hope you can help with. I am building an app which has a main menu of tabs.
1. Each tab calls a separate php page. Within that page, users can update, sort, select, etc. which requires a post of the page itself. If I implement ajax call as you have done in the demo, it updates every time I select the tab, but if I try and post it brings up the page over my main page. If I implement as non-ajax with a div and an iframe within the div, then the page itself works fine within the iframe, but does not refresh when I re-select the tab. Any thoughts?
2. Is there anyway to prevent clicking another tab until the user has selected either save or cancel on the tab they are on? Otherwise I can see people filling in the form and then navigating away without saving.
Sorry it’s so long, but wanted to give as much as I can since I can’t show it to you directly.
Once again, many thanks for your work, and I hope the answer is easy!
Cheers
Ross Holland
code in tabset, in , in SMARTY don’t work.
How to put in SMARTY?
Sorry but I don’t know how Smarty works…
to insert jscript or css in smarty -php just use the tag {literal}{/literal} like this
css
{literal}
TD {border: none; font-size: 8pt}
{/literal}
or js(jquery)
{literal}
{/literal}
Hi Matteo,
Nice looking set of tabs. Simple to implement. I have a question. Is there an event that fires or a way to register a callback as the user switches tabs? I have 5 tabs with forms on each and I would like to set the focus() to the first form field input on the tab as the user switch to it.
Ken
Hi Ken,
you are right, actually thers no callback function for tab selection…
to solve your problem you can modify mb.tabset.js:
add after line 65:
add after line 90:
change line 93:
on your page you can now add as metadata the function you need:
Hope this is clear,
Bye,
matteo
[...] Posted by hoirul07 in JQUERY. Leave a Comment tekanan demi tekanan datang dan memaksa untuk mencoba seni design, setiap tampilan yang aku buat selalu terlihat kurang bagus dimata client. hingga akhirnya lihat plugin JQuery Mtab jquery mtabs [...]
Hi Matteo,
Great plugin! It is great to be able to deliver a tab set such as this on my intranet page.
But I am having a problem with Ajax content or I believe it is ajax. And it is on IE8…
Each one of my tabs refers to other pages through ajax but as soon as I go to another tab I get the error:
” ‘theform.elements.length’ is Null or not an object”.
If I ignore the error and go back and forth through the tabs I eventually get an error box stating:
SysFader:iexplorer.exe – App;ication Error
The instruction at “an address” referenced memory at “that address”. The memory could not be “written”.
Funny enough (or not funny) I have tried it using FF and there is no problem. But I need to have it working in I.E..
Would you have any suggestions?
cheers
Glen
Hi Glen,
Can you be more specific with the javascript error?
can you inspect the code with the Developer Tool of IE8?
That could be helpful to understand the error type and if it depends by the Ajax or maybe by some HTML code that get broken by the Ajax call…
Bye
Matteo
Hi Matteo,
I have had a small win with this issue although it may not be the answer for all.
Line 541 & 542 of the jquery-1.4.2.js was causing my problem. This seems to end up with some type of Postback in some lower level js I did not have access to. In the time honoured “trial & error” debugging methodology I decided to comment out:
and it worked (for me). I have had no resulting issues with this in the last few days.
Maybe somebody else could put there finger on why this works for me.
And yes I used the IE 8 Developer tool to narrow this down.
I hope this may help somebody else
Glen