Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Tools tabs conflicts with JQuery UI

I'm using JQuery tools' tabs feature and at the same time I use JQuery UI.

If I include both JS libraries, Jquery tools with tabs does not work.

How to fix this conflict? Any help is appreciated.

Thanks in advance.

like image 481
Emir Avatar asked Jan 05 '11 00:01

Emir


3 Answers

You could get a custom jQuery-ui build that that doesn't include the tabs but that might cause some confusion later on. A better approach, IMHO, would be to edit the jQuery-tools tabs.js and change this line:

$.fn.tabs = function(query, conf) {

to something like this:

$.fn.fpTabs = function(query, conf) {

I used "fpTabs" for "flowplayer.org tabs", you can use whatever name works for you. That should clear up your conflicts without causing problems anywhere else. Of course, you'd have to remember that you changed tabs.js if you ever upgrade but that should be less troublesome than messing around with a tab-less jquery-ui.js file.

like image 169
mu is too short Avatar answered Nov 17 '22 13:11

mu is too short


There is an easier method. Whenever you use jquery with other libraries (Tools | Prototype | MooTools | etc.) you can use a special noConflict function to re-assign the $ to another variable. For example:

var $j = jQuery.noConflict();    // assign the main jQuery object to $j
$j("#tabs-container").tabs();    // use $j as you would normally use $

Or you can be more explicit and use jQuery.someFunction() instead of $.someFunction.

like image 32
RADA Avatar answered Nov 17 '22 12:11

RADA


You can build your own jquery UI in this url http://jqueryui.com/download

only pick tools you need and do not include component TAB in the options to avoid conflict with jquery tools

enter image description here

like image 5
risnandar Avatar answered Nov 17 '22 12:11

risnandar