I discovered that the meta-data plugin wasn't all I wanted, so I  
wrote a very small plugin to store and fetch json from the class  
attribute.

$(element).json() will return a json-string stored in the class  
attribute from the first matched element
$(elements).json(string) will set the json-string in the class  
attribute for all matched elements

comments as always welcome :)

Andreas

code:
jQuery.fn.json = function(value) {
     if (typeof(value) == "string") {
         return this.each(function() {
             if (this.className.match(/\{.*\}/)) {
                 this.className = this.className.replace(/\{.*\}/,  
value);
             } else {
                 this.className = this.className + ' ' + value;
             }
         });
     } else {
         return (eval('(' + this[0].className.match(/\{.*\}/) + ')'));
     }
};

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to