[Seaside] inline javascript inside head section

Philippe Marschall philippe.marschall at gmail.com
Sat Jan 26 19:27:16 UTC 2008


2008/1/26, Gerhard Obermann <obi068 at gmail.com>:
> I want to create a javascript inside the head section
> without doing a callback.
>
> I tried the following code:
>  anHtmlRoot javascript add: 'function test() {.....}'

Right, we need the same hacks that we currently have for <script> in
the body in the head as well.

Issue created:
http://bugs.squeak.org/view.php?id=6875

Seaside-Tests-pmm.21 has a test for this bug:

WAHtmlRootTest >> #testJavascript
	self
		assert: [ :html |
			html javascript
				add: 'true & false'  ]
		gives: '<title></title><script
type="text/javascript">/*<![CDATA[*/true & false/*]]>*/</script>'


> The problem is, that in this case the javascript will be also encoded and
> this
> breaks my javascript code.
>
> The only solution i found up to now, is to override the encodeOn: method in
> WAScriptElement
>
> encodeOn: aDocument
>  aDocument openTag: self tag attributes: attributes closed: self isClosed.
>  self isClosed ifTrue: [ ^ self ].
>  self childrenDo: [ :each | aDocument nextPutAll: each].
>  aDocument closeTag: self tag

If this functionality is critical for you and you can't put the script
in an external file then this quick hack should work. Note however
that your page is unlikely to validate against XHTML. You can change
your doctype to HTML if validation is important to you.

> btw: i am using seaside 2.9

Wow.

Cheers
Philippe

> cheers Gerhard
>
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>


More information about the seaside mailing list