Re: Seaside function onLoad problematic
Paul DeBruicker <[email protected]>
| Newsgroups | gmane.comp.lang.smalltalk.squeak.seaside |
|---|---|
| Message-ID | <[email protected]> |
Hi Dario Instead of rewriting how the strings are encoded you could maybe try html document addLoadScript: (JSStream on: ‘so_initdtr()’) [email protected] wrote > 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 " > > > > > > 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: > > > > > 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@ > 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: >>> >>> >>> >>> 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 >>> > [email protected] >>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside >> >> _______________________________________________ >> seaside mailing list >> > [email protected] >> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > > > _______________________________________________ > seaside mailing list > [email protected] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside -- View this message in context: http://forum.world.st/Seaside-function-onLoad-problematic-tp4924859p4925037.html Sent from the Seaside General mailing list archive at Nabble.com. _______________________________________________ seaside mailing list [email protected] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside