Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent jquery UI from adding styles automatically?

I'm wondering what is the easiest way of telling jquery UI not to add style classes? I am trying to use the tabs plugin, which has a lot of functionality I want... but I actually want it to do NOTHING when it comes to styles. I want to be in total charge of it, because frankly, the defaults are too busy and just don't work for a minimlist design.

I found a similar question here...: jquery ui tabs major style change

... But they never got around to preventing the classes from being added in the first place.

You can just refuse to load the css theme at the top of the document, but then the tabs widget just ceases to work despite not causing any javascript errors. The entire situation is just awful to be in, and I'd hate to have to program my own tabs widget just because jquery UI refuses to let me use my own styles :(

Help?

like image 622
egervari Avatar asked Dec 17 '10 17:12

egervari


People also ask

Is jQuery UI still maintained?

In its heyday, jQuery UI was adopted by a broad set of enterprises including Pinterest, PayPal, IMDB, Huffington Post, and Netflix. Today, jQuery UI continues to be an important testbed for jQuery Core updates, helping the maintainer team spot bugs and interoperability issues that arise as the web platform evolves.

Why would someone use the jQuery UI plugin?

jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Whether you're building highly interactive web applications or you just need to add a date picker to a form control, jQuery UI is the perfect choice.


2 Answers

If you want existing styling, with the exception of some widgets (tabs), you could add an outer div#mytabs and then override any default styling applied by jquery UI.

Quick (rough) demo to illustrate my point.

#mytabs #tabs2 ul.ui-tabs-nav{
    background:lime;
    border-radius:0;
}
#mytabs #tabs2.ui-tabs, #mytabs #tabs2.ui-widget{
    border:magenta;
    border-radius:0;
    background:cyan;
}

This would give you the option of using the default styling (even of tabs) in a different area. You could, of course, just change the styling (or again, do overrides) on the .ui-tabs-nav classes.

like image 178
jyoseph Avatar answered Sep 27 '22 22:09

jyoseph


If you're looking for a jQuery UI option that prevents the adding of classes, you are out of luck.

Your best bet is as @brett suggested, make a minimalist theme. Alternatively, I can imagine a javascript function that given an DOM element, searched through it and children looking for a list of classes in their class attribute, then removing each one. Seems evil though!

like image 39
Ryley Avatar answered Sep 27 '22 22:09

Ryley