[Seaside] How can I invoke the callback of an anchor using jQuery?

Johan Brichau johan at inceptive.be
Mon Mar 14 11:17:22 UTC 2011


Jan,

A callback will always trigger a full page rendering. The callback mechanism works with a url in the anchor and therefore the browser expects a complete html page as a response.
Instead, try to do something along the lines of:

html anchor
	url: 'javascript:{}'; 
	onClick: (html jQuery ajax script: [ :s |
			self doSomething;
     			 s << (s jQuery: 'mydiv')
         				html: [ :r | self renderMyDivOn: r ] ]) ;
	with: 'doit'.

Basically: include the action inside the ajax callback, right before invoking the rendering. 
If you want to separate the blocks, you will need to use a callback: [...]; onComplete:[...] construction, I think.
Overriding of the url has proven necessary to me to avoid default browser behavior.

Johan
	
On 14 Mar 2011, at 11:49, Jan van de Sandt wrote:

> Hello,
> 
> If I have an anchor with a callback:
> 
> html anchor
>    callback: [ self doSomething ] ;
>    with: 'DoIt'.
> 
> Now I want to use jQuery to update only part of the page instead of a full page reload:
> 
> html anchor
>    callback: [ self doSomething ] ;
>    onChange: (html jQuery ajax script: [ :s |
>       s << (s jQuery: 'mydiv')
>          html: [ :r | self renderMyDivOn: r ] ]) ;
>    with: 'DoIt'.
> 
> How do I make sure that the callback is performed before the render method is executed? With form elements you can use serializeThis but I guess that doesn't work for anchor elements.
> 
> Jan
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



More information about the seaside mailing list