[Seaside] Re: Issue with JSScript code generated in a render
John Toohey
jt at parspro.com
Thu Mar 4 21:49:01 UTC 2010
Digging a little deeper the problem seems to with the #javaScript
method of CTPusher. By escaping the / slash in this method, the
browsers do not complain, so the code I send is like this :-
<script type="text\/javascript">parent.Comet.eval("$(\"#markettable\").append(\"<tr><td
rowspan=\\\"1\\\" class=\\\"collapsible\\\"></td><td><span
class=\\\"grids\\\">1X2</span></td><td><span class=\\\"bold\\\">1x2
test 5</span></td><td><input id=\\\"hp168\\\" size=\\\"4\\\"
onchange=\\\"$.ajax({url:"/",data:["1",$(this).serialize()].join("&"),dataType:"script"})\\\"
value=\\\"1.0\\\" name=\\\"2\\\" type=\\\"text\\\"
class=\\\"text\\\"/></td><td><span class=\\\"bold\\\">Hello
World</span></td></tr><script
type=\\\"text/javascript\\\">/*<![CDATA[*/$(\\\"#hp168\\\").spinner({min:1,max:99,step:0.25,increment:\\\"fast\\\",skipInitialChange:true,showOn:\\\"always\\\"})/*]]>*/</script>\")")<\/script>
The browsers report no errors, but the TR does not get appended to the
table. If I remove the spinner script, the TR does get appended.
On Thu, Mar 4, 2010 at 14:50, John Toohey <jt at parspro.com> wrote:
> I ran into an issue pushing data and a script via Comet to a brower.
> My render generated correct HTML, plus this code :-
>
> <script type=\"text/javascript\">/*<![CDATA[*/$(\"#hp169\").spinner({min:1,max:99,step:0.25,increment:\"fast\",skipInitialChange:true,showOn:\"always\"})/*]]>*/</script>")
>
> This looks okay, but both FF and Chrome generate an error while
> parsing it. FF mentions "unterminated string" and Chrome complains of
> an Invalid TOKEN. I reduce the code to :-
> $("#markettable").prepend(
> "<script></script>"
> );
> but this still gives an error.
>
> However, adding escaping the final forward / in the script tag fixes
> this. I found a lot of reports of this issue on the net, and the
> consensus seems to be to always escape a forward / whilst emitting JS
> to the browser. Having trouble finding the method that generates the
> tags, do anyone know where that is?
>
> --
> -JT
>
--
-JT
More information about the seaside
mailing list