17

Does jQuery - or one of it's plugins - have equivalent functionality to the YUI StyleSheet Utility?

"The StyleSheet Utility is capable of creating new stylesheets from scratch as well as modifying the existing stylesheets held as properties of elements sourced from the same domain or any inline elements."

This (I'm fairly sure) is creating and modifying CSS stylesheets themselves not looping through the DOM and changing element's style property (as the jQuery.css() method does).

I think this technique has the potential to significantly change the way a lot user interface related Javascript is written so would be interested to hear about any other libraries where it's been implemented too.

edeverett
  • 8,012
  • 33
  • 28
  • I have my doubts on it's abilities to change UI. You can store unused CSS rules in the style-sheet and simply modify the class attribute. It's never really necessary to loop through style properties. – Ian Elliott Jul 03 '09 at 13:36
  • But for instance this opens up the possibility of calculating values for style properties in JS and applying the changes with proper CSS rules rather than using style properties. – edeverett Jul 03 '09 at 13:54
  • Ah! Maybe I'm not clear when I say UI - by UI I meant "user interface" rather than "jQuery UI". Edited question for clarity. – edeverett Jul 03 '09 at 14:05
  • I know there was a jQuery plugin that let you alter the CSS o a page exactly the way you said. I don't remember its name though. – Ionuț G. Stan Jul 03 '09 at 15:21
  • @edeverett I guess I can see how it would be useful in that instance, and I did know you meant regular UI :) – Ian Elliott Jul 03 '09 at 16:39

2 Answers2

18

Found a couple that look like they do similar things. I haven't tested them. jQuery.Rule looks to be pretty good though

jQuery.Rule by Ariel Flesler

This plugin allows quick creation/manipulation of CSS Rules, in a "jQuery-way". It includes features like chaining, iteration using each, selectors with context.

GlobalStylesheet by Jeremy Lea

Enables CSS modification that uses a 'global' stylesheet, rather than inline CSS. This is particularly handy for modifying CSS styles that you want to remain persistent until a page is refreshed again.

Dan F
  • 11,958
  • 3
  • 48
  • 72
0

The short answer is no. YUI is the avant garde in this matter.

However I fully expect there to be something similar being made in the coming weeks(months), as the methodology that YUI is using does not seem to be unreplicable and considering how useful and important this feature is.

Maybe study YUI's method and make a plugin yourself?

Edit: Looks like I'm wrong. This is why you never post negatives like this. :)

Mark
  • 32,293
  • 33
  • 107
  • 137
  • Thanks for the answer. I'll certainly be investigating how YUI get it to work but I think I'll leave writing the plugin to someone with more skills than myself. – edeverett Jul 03 '09 at 15:22