[Seaside] Seaside function onLoad problematic

dtrussardi at tiscali.it dtrussardi at tiscali.it
Mon Nov 28 10:22:51 UTC 2016


Ciao Johan,


	i add the A B C considerations.

> Hi Dario,
> 
> Try:
> 
> html document addLoadScript: (html javascript: ‘so_initdtr()’)

A)	The:	 html javascript:  	is not supported by the system

			The call answer: 	" you sent a message this type of object doesn't understand"

> 
> As you can notice in the generated html output, the contents of the loadscript is a JS string.

	Yes but into it the so_initdtr() is surround by the "

		<script type="text/javascript">function onLoad(){"soinitdtr()";};</script>



B)	I change the 		JSStream 		 encodeString: aString on: aStream   metod

	removing the initial and final 	 "aStream nextPut: $'."  ( view the **** )

	 encodeString: aString on: aStream 
	"Strings have a complicated encoding in Javascript, try to optimize their serialization."
		
****  "aStream nextPut: $'."
	
	1 to: aString size do: [ :index | 
		| char value encoded |
		char := aString at: index.
		value := char greaseInteger.
		value < JavascriptCharacters size 
			ifFalse: [
				"U+2028 and U+2029 have to be treaded as new lines"
				value = 16r2028 "Line separator"
					ifTrue: [ aStream nextPutAll: '\u2028' ]
					ifFalse: [
						value = 16r2029 "Paragraph separator"
							ifTrue: [ aStream nextPutAll: '\u2029' ]
							ifFalse: [ aStream nextPut: char ] ] ]
			ifTrue: [
				encoded := JavascriptCharacters at: value + 1.
				"we use nil markers becausee #isNil is faster than #isString because it's not
				actually sent"
				encoded isNil 
					ifTrue: [ aStream nextPut: char ]
					ifFalse: [ aStream nextPutAll: encoded ] ] ].
**** "aStream nextPut: $'"


	With this modification my code works fine.

	The browser  report:

		 <script type="text/javascript">function onLoad(){so_initdtr();};</script>


	But with this change the JQuery example don't works.


C)	My final considerations is relative to the WAScriptGenerator	 writeLoadScriptsOn: aDocument		metod 

	I change it to the seaside 3.0 version: 

	writeLoadScriptsOn: aDocument
	"Utility method to write the receivers load scripts onto aDocument."

	" *** ----
		self loadScripts do: [ :each |
		aDocument stream javascript: each.
		aDocument  nextPut: $; ]"
	
	"**** +++ "
	self loadScripts do: [ :each |
		aDocument nextPutAll: each greaseString; nextPut: $; ]

	With just this change everything works, but it is in the right direction?


	Thanks,

		Dario

> 
> cheers
> Johan
> 
>> On 26 Nov 2016, at 19:00, dtrussardi at tiscali.it wrote:
>> 
>> Ciao,
>> 
>> 	into Pharo5.0 with Seaside 3.2 ( but i have the same problematic into Pharo 4.0 with Seaside 3.1 )
>> 
>> 	when define a function to load when the page has finished loading
>> 
>> 		with	 addLoadScript: 'so_initdtr()'.
>> 
>> 	the function is not called.
>> 
>> 
>> 	For example:
>> 
>> 
>> 	renderContentOn: html
>> 
>> 		html document addLoadScript: 'so_initdtr()'.
>> 	
>> 		html heading: 'Pippo'.
>> 
>> 
>> 	The html report: 
>> 
>> 		<script type="text/javascript">function onLoad(){"soinitdtr()";};</script>
>> 
>> 	but the browser don't call it when load the page.
>> 
>> 	The relative javascript code is right loaded into the browser.
>> 
>> 	I can call the	 	so_initdtr()	function with the browser console and it works fine.
>> 
>> 
>> 	Thanks in advance!
>> 
>> 	Dario
>> 
>> 			
>> _______________________________________________
>> seaside mailing list
>> seaside at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> 
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/seaside/attachments/20161128/da3c9ffc/attachment-0001.html>


More information about the seaside mailing list