[Seaside] Jquery select then hide

Johan Brichau johan at inceptive.be
Tue Apr 28 07:21:05 UTC 2015

Hi Hilaire,

I wonder: do you really need the value server-side?
If you just want to manipulate the DOM but not send any value server-side, I would do it like this:

(field := mold at: #civility)
   onChange: (html jQuery this value) equals: ‘missis’ asJavascript
				then: (html jQuery: #maiden) show
                 		then: (html jQuery: #maiden) hide)

This will avoid doing a server-side call and has the advantage of immediate updating on your webbrowser without the delay of a server round-trip.

Also, in this case, the generation of the javascript is small and readable, but for such ‘static’ javascript, it’s better to put them in a separate file and only call the necessary function from your Seaside code. For example:

(field := mold at: #civility)
   onChange: (html javascript call: ‘maidenToggle’ with: (html jQuery this))


> On 27 Apr 2015, at 10:50, Hilaire <hilaire at drgeo.eu> wrote:
> Thanks for your tips.
> Based on your tips, I have to do it a bit differently as my select list
> is built from symbols (#mister, #miss #misses) and Seaside in that case,
> only store index number in the option list value attribute:
>          <option value="1">Madame</option>
>          <option value="2" selected="selected">Mademoiselle</option>
>          <option value="3">Monsieur</option>
> Therefore the (JSStream on: 'options[selectedIndex].text') sent to the
> ajax callback these index number (1 2 or 3) and not my symbol.
> However I discover the 'html jQuery ajax serialize:' does two things:
> send the jqueried input field value to the server and fire its Seaside
> callback, where my symbol are known.
> (field := mold at: #civility)
>    onChange: [ :aHtml |
>        html jQuery ajax
>            serialize: html jQuery this;
>            script: [ :s |
>                field input == #missis
>                    ifTrue: [s << (s jQuery: #maiden) show]
>                    ifFalse: [s << (s jQuery: #maiden) hide]]
> Now it seems to work locally, but stuff is uncoupled and asynchrone:
> do I have the risk the script is fired before the serialize is terminated?
> Thanks
> Hilaire
> Le 27/04/2015 00:57, Bob Arning a écrit :
>> This works for me:
> -- 
> Dr. Geo - http://drgeo.eu
> iStoa - http://istoa.drgeo.eu
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

More information about the seaside mailing list