[Seaside] Adding javascript without encoding

Sebastian Van Lacke svanlacke at caesarsystems.com
Mon Nov 23 14:04:44 UTC 2009


Hi list, I need to add some javascript on the document head to achieve this:

<script language="javascript" type="text/javascript">
  $(function() {
   $( "#example_2" ).accessNews({ 
         speed : "normal",
   slideBy : 1
     });
 });
</script>

I add the script on the updateRoot method:

Component >>updateRoot: aRoot
 
 super updateRoot: aRoot.
 aRoot javascript add: self example2Script.

Component>>example2Script

 ^'$(function() {
  $( "#example_2" ).accessNews({
         speed : "normal",
   slideBy : 1
     });
 });'

but the problem is that Seaside by default, encodes this string with an HTML enconder, generating this string embeded on the document

<script type="text/javascript">
$(function() { 
    $( &quot;#example_2&quot; ).accessNews({  
        speed : &quot;normal&quot;, 
        slideBy : 1 
    }); 
  });
</script>

where the $" are replaced by '&quot' . And the script doesn't work!!.
I need to put the string without enconding. Which is the correct way to do it? 

I do it by redefining a Seaside method, but I suppose there's some other clean solution.
I have redefined this method:

encodeOn: aDocument
 aDocument openTag: self tag attributes: attributes closed: self isClosed.
 self isClosed ifTrue: [ ^ self ].
 self childrenDo: [ :each | each encodeOn: aDocument ].
 aDocument closeTag: self tag

to:

WAScriptElement >> encodeOn: aDocument
 aDocument openTag: self tag attributes: attributes closed: self isClosed.
 self isClosed ifTrue: [ ^ self ].
 self childrenDo: [ :each | aDocument nextPutAll: each displayString].
 aDocument closeTag: self tag.

Thank you!!

Sebastian


sebastian  van lacke | developer |  caesar systems | see clearly. decide smarter.
svanlacke at caesarsystems.com | t: +1.281.598.8790 | t: +54.11.4389.0126 | www.caesarsystems.com 

This message and any attached documents contain information from Caesar Systems LLC that may be confidential/trade secret and/or privileged. If you are not the intended recipient, you may not read, copy, distribute or use this information. If you have received this transmission in error, please notify the sender immediately by telephone or by reply e-mail and then delete this message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20091123/43e3845f/attachment.htm


More information about the seaside mailing list