views:

161

answers:

2

I am developing an application using jQueryUI. I am also using the Themeroller. I want to have as many of my styles as possible defined using the theme, so that if I need to change some styles, I simply have to create a new custom theme (or download an existing theme).

I am trying to use the "selectable" interaction in jQueryUI. It is working as it should - in Firebug I can see the "ui-selected" class being applied to the element that I select. However, there is no visual cue that the item has been selected. I looked in the theme CSS file (jquery-ui-1.8rc3.custom.css, which I downloaded from the Themeroller page), and I see no declaration for the "ui-selected" class. When I downloaded jQueryUI and the theme, I checked every option, including the one for "selectable".

How can I make my theme define the "ui-selected" class? Obviously, I could just create my own style declaration, but that solution is not ideal if I ever want to change the theme.

I am using jQuery 1.4.2 and jQueryUI 1.8rc3.

A: 

Sorry the answer sucks, but you can't.

This is functionality the ThemeRoller would have to have added, nothing you can do to add to it's generated styles automatically.

If you look at the demo pages, they also manually make the style declarations for .ui-selected

Nick Craver
That is what I was afraid of, but I figured I would ask anyway. This statement on the demo page (in the Theming tab) made me think it was possible:"The jQuery UI Selectable plugin uses the jQuery UI CSS Framework to style its look and feel, including colors and background textures. We recommend using the ThemeRoller tool to create and download custom themes that are easy to build and maintain."
Jeremy
@Jeremy - I would definitely add a request for this if there isn't one in already. Unfortunately I can't say if there is at the moment because the jQuery UI ticket system is down, but it should be fixed soon: http://dev.jqueryui.com/report/10?P=selectable
Nick Craver
+1  A: 

You can dynamically set the ui classes as this :

$("#selectable ul").selectable({
  unselected: function(){
    $(".ui-state-highlight", this).each(function(){
      $(this).removeClass('ui-state-highlight');
    });
  },
  selected: function(){
    $(".ui-selected", this).each(function(){
      $(this).addClass('ui-state-highlight');
    });
  }
});
$("#selectable li").hover(
  function () {
    $(this).addClass('ui-state-hover');
  }, 
  function () {
    $(this).removeClass('ui-state-hover');
  }
);
Eureka