Paul McLanahan schrieb: > @jake > I'm really liking the <code> tag idea. If I'm understanding you > correctly, it would work something like associating a label to an input > using the "for" attribute. I'd just be associating a code tag's > contents with a specific DL either by location in the markup or maybe by > some specific classes. That might prove to be the easiest and most > semantically correct solution. > > I don't know about you guys, but this situation has come up a lot in JS > I've written and want to write. So if we could standardize a "jQuery > way" of accomplishing this then I think it would be helpful to all > plugin authors. Much like the standardization of the options object > overriding the defaults using $.extend in the plugin docs. Right now > I'm liking Jake's suggestion. My thinking is that it would work > something like this (not tested): > > // get options (assuming we're in an each loop and "this" is a DL node) > if($(this).prev().is('code')){ > eval("thisOpts = {" + $(this).prev('code').text() + "}"); > $.extend(options,thisOpts); > } > > Which would work on some markup like this: > > <code>accordion:false,showSpeed:'slow',hideAll:true</code> > <dl class="accordion"> > <dt>click me</dt> > <dd>to show me</dd> > </dl> > > Then either hide all code tags in the CSS or give the code tag a class > if you don't want to hide them all. > > Thoughts?
Ouch, that is obtrusiveness at its best. Maybe Obtrusive 2.0 or something. I'd simply use the class attribute for options, that is what its intended for (yes, it's not only for styling things): "The class attribute, on the other hand, assigns one or more class names to an element; the element may be said to belong to these classes. A class name may be shared by several element instances. The class attribute has several roles in HTML: * As a style sheet selector (when an author wishes to assign style information to a set of elements). * For general purpose processing by user agents." http://www.w3.org/TR/html4/struct/global.html#h-7.5.2 The code element is not supposed to hold script to be executed. There is an element called script, that does that. Or does anybody put his jQuery into a code element and eval it? -- Klaus _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/