<script type="text/x-jquery-json">alert("Was run as JS.")</script>
<script type="text/x-jquery-json">{accordion:false,stuff:"Whatnot"}</script>
<dl class="jaccordion"></dl>
<script type="text/_javascript_">
$(function(){
$('dl.jaccordion').each(function(){
if($(this).prev().is('script')){
eval('thisOpts='+$(this).prev().html()+';');
alert(thisOpts.stuff);
}
});
});
</script>
Very very cool. Perhaps a combination of both is in order. The 2 class with useful multiple defaults definitions method for ease of use, and then also check for the script tag as it's previous sibling as a method for overriding the defaults for the more JS literate. I should probably use is('[EMAIL PROTECTED]"text/x-jquery-json"]') to be more specific. Very very nice. Now to make the code small too :)
PS - I tried the text() method when getting the contents of the script tag, but it caused a blank alert box to fire in IE7. No time to debug that for now. Fortunately the html() call instead remedies the problem. Weird.
On 10/31/06, Ⓙⓐⓚⓔ <[EMAIL PROTECTED]> wrote:
from the very early days of the <script> tag... if the browser doesn't
know how to do it, it must silently ignore it... does it still get
slipped into the dom? in every browser? DUNNO! It works in FF &
Safari.
_______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/