[Seaside] Re: onSuccess: problem

Esteban Lorenzano estebanlm at gmail.com
Sat May 10 02:10:56 UTC 2008


It is so easy! I'm feel like a dumb... I tried everything, except that.
Thanks!

Esteban

On 2008-05-09 21:34:46 -0300, "Ramon Leon" <ramon.leon at allresnet.com> said:

> 
>> Hi all,
>> I'm having problems with html request... onSuccess:, this is
>> what i'm doing:
>> 
>> 	html anchor
>> 		class: #eventRefresh;
>> 		onClick: (
>> 			(html request
>> 				callback: [ Transcript show:
>> 'REQ'; cr ];
>> 				onSuccess: 'window.alert("OK")';
>> 				onFailure: 'window.alert("Failure")'));
>> 		with: [ html image url: SushiLibrary / #addPng ]
>> 
>> This is rendering all ok ('REQ' is being written on
>> transcript window)
>> ... but onSuccess (or onFailure) is not being called after it...
>> 
>> This is de javascript generated with that call:
>> 
>> new
>> Ajax.Request('http://localhost:8080/seaside/Sushimoto',{'onSuc
>> cess':function(){'window.alert("OK")'},'onFailure':function(){
>> 'window.alert("Failure")'},'parameters':['_s=BeRHEehLgPOyfdJU'
>> ,'_k=zvZqQkjr','11'].join('&')})
> 
> onSuccess: (html alert: 'OK')
> 
> If you look at how #alert: is implemented...
> 
> alert: anObject
> 	self add: (SUStream new
> 		nextPutAll: 'alert';
> 		argument: anObject;
> 		yourself)
> 
> Then you'll see how to use SUStream manually to feed hand written JavaScript
> into #onSuccess:.  Scriptaculous events like #onSuccess: do not work like
> Seaside events like #onClick: or #onChange:.  Seaside events assume they're
> being handed JavaScript and they just run whatever you give them, but
> Scriptaculous events call #asFunction on whatever you give them, so when you
> give them a string, they wrap a function around it...
> 
> function(){'window.alert("Failure")'}
> 
> Which basically won't do anything.  So if you want hand written JavaScript,
> do this...
> 
> onSuccess: (SUStream on: 'window.alert("OK")')
> 
> And it'll work.
> 
> Ramon Leon
> http://onsmalltalk.com





More information about the seaside mailing list