Adding javascript without encoding

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding javascript without encoding

Sebastia Van Lacke
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.

[hidden email] | 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.


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Adding javascript without encoding

Lukas Renggli
I assume that you are in Seaside 2.8, because this problem seems to be
fixed in Seaside 3.0?

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

You probably should use #document: instead of #add:

  aRoot javascript document: self example2Script

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside