jQuery multiple themes on one page
Asked Answered
M

2

6

This is driving me NUTS! I've followed the post here which just doesn't seem to be working: http://www.filamentgroup.com/lab/using_multiple_jquery_ui_themes_on_a_single_page/

I have a base theme, for examples sake it's the Smoothness theme from the jQuery UI gallery. Then I have a 'red' theme which basically colours the buttons red. Here is the theme I created.

So I go to download my theme. Choose Advanced settings, set the scope to 'red' and my theme folder name to 'red' and download. First of all I'm not entirely 100% sure which folder I'm to copy over to my project is it the 'development-bundle\themes' folder (which contains my red folder) or the '\css\red' folder?

I've tried both. The post above seems to suggest if I copy my themes folder and link to my theme in the css it'll work when I add a class of 'red' to a wrapper div or element. So I've linked the themes like so in my file:

<link type="text/css" href="themes/base/jquery.ui.all.css" rel="stylesheet" />
<link type="text/css" href="themes/red/jquery.ui.all.css" rel="stylesheet" />

The base theme loads and works all honkey doorey but the red theme doesn't. I've got a button styled like so:

<input type="submit" id="btn" value="A submit button" class="red" />

I've also tried:

<div class="red">
    <input type="submit" id="btn" value="A submit button" />
</div>

Neither work. When I remove the 'themes/base/jquery.ui.all.css' css file link the button's aren't styled at all. Crazy! I'm pulling my hair out. Where am I going wrong? Surely they should just make it easy enough to download JUST the theme folder and reference the ui.all file.

Matz answered 1/6, 2010 at 0:43 Comment(2)
I haven't tried it, but I know jQuery can break at small things. Did you put .red as the scope and not just red? Also, try themes/red/ui.all.css" instead of themes/red/jquery.ui.all.css".Farrago
I tried the .red yesterday before I posted and that didn't help (I had to go and edit the css file that the themeroller created to change it all to .red). I'll try the change in the file name in a moment and let you know.Matz
P
1

I have added a new css class for red icons:

Icons
----------------------------------


/* states and images */

.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
.ui-iconRed { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }

And change here too:

/* states and images */

.ui-icon { width: 16px; height: 16px; background-image:url(images/ui-icons_469bdd_256x240.png); }

.ui-iconRed { width: 16px; height: 16px; background-image:url(images/ui-icons_470bdd_256x240.png); }

I have a folder with the red and blue images. When I want take a red image I just reference the class iconRed, like this:

 <img class="ui-iconRed ui-icon-bullet"  title="Vendido" style="float: left;" />

 //if want a blue just put the normal icon like this:

 <img class="ui-icon ui-icon-bullet" title="Não vendido" style="float: left;"  />
Paleoasiatic answered 14/11, 2011 at 20:0 Comment(0)
C
0

Skoders right.

You have to use the element id, class or tagname in the JQuery notation.

  • For a class: .class
  • For an id: #id
  • For the tagname: table

You'd best choose the class way, since it isn't just more classy than the others but much more usable (it can be used on multiple objects) and you don't mess up any layout elements like divs or tables. After all, the css scope justs adds the provided value to each css definition. i.e.

.ui-icon { ... }

becomes

.scope .ui-icon { ... } 

Edit: Make sure you included the right stylesheet, I got the whole thing working with the following code

<html>
    <head>
        <title>JQuery UI Theme Scope</title>
        <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
        <script type="text/javascript" src="js/jquery-ui-1.8.1.custom.min.js"></script>
        <link type="text/css" href="css/red/jquery-ui-1.8.1.custom.css" rel="stylesheet" />
        <link type="text/css" href="css/default/jquery-ui-1.8.1.default.css" rel="stylesheet" />
    </head>
    <body>
        <input type="submit" class="ui-state-default ui-corner-all" value="Submit" />
        <div class="red">
            <input type="submit" class="ui-state-default ui-corner-all" value="Submit" />
        </div>
    </body>
</html>

Don't link to the stylesheet in the "developement-bundle" directory, use the one in the "css" directory instead.

Christoper answered 1/6, 2010 at 20:28 Comment(1)
I am using class. The problem is I can't get the red scope to load in and override the base theme by setting the class name.Matz

© 2022 - 2024 — McMap. All rights reserved.