Blair McKenzie-2 wrote: > > Is there any reason not to simply use a javascript snipit in a script tag? > There are good reasons to put code at the start of a page or in a separate > file, but in this case I would say that putting it at the top of the > relevant tag is perfectly reasonable: > <ul id="list_xyz"><script>$("#list_xyz").attr("accordion > :settings","accordion:true,showSpeed:'slow',hideSpeed:'fast'")</script> > </ul> > This implementation can probably be improved, but the concept seems fine. > > Blair > >
I'm totally agreed. Script is the right tool to be used for. Although in simple situations using class attribute seems to be concise and elegant, however using script: 1. allows for more structural building of attribure tags; 2. uses natural JSON syntax without external parsing. I'm currently (still) not using JQuery, but I want to get deep into it. In my widget framework, I'm using following syntax to pass individual attributes into specific widgets (do not go deeply into semantic of the example, this is only for showing syntax possibilities from real-life construction): <div class='widget WinView' id='WinView2' title='Print from window'> <script> var WinView2 = document.getElementById('WinView2'); WinView2.options = { ScaleMode : 1 } WinView2.bindings = { DocsNavig1 : [] } WinView2.layout = { LinkUrl : 'GetPrint.asp?', LinkName : 'Print', WinName : 'Print', WinWidth : 600, WinHeight : 800 } </script> </div> Attributes can be easily structured, named, and directly applied to JS objects concerned with widgets based on HTML div's so that they can be instantly and semantically accessed in code serving widget functionality. Sample given by Blair shows how this solution can be implemented in JQuery presence. In context of whole discussion, the concept of client-code markup using <script type="text/xml-script"> tag like in Atlas XML Script or using <xml> tag islands (not fully supported among browsers, but <code class="hidden"><xml></xml></code> - after Jake's proposal - can be always used) should be mentioned as well. However, it requires client side parser of XML (could JQuery possibilities be used against this?) Other solutions may be implemented using microformats concept. Personally, I prefer using script tag with JSON structured attributes. I'm very interesed in opinions of more experienced JQuery users/contributors/authors in this matter. Krzysztof -- View this message in context: http://www.nabble.com/Plugin-method-question-tf2543741.html#a7092282 Sent from the JQuery mailing list archive at Nabble.com. _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/