[Seaside] getting a single value through jQuery

Richard Durr richard.durr at googlemail.com
Wed Oct 7 08:23:40 UTC 2009


Cool, thank you for the explanation! :)That helped a lot, especially the
last part about using #script: and about using #closest: . I couldn't figure
it out for myself since I'm sometimes too insecure what methods to use when
and what their semantic is, sigh.
Is something like the following actually possible at all?

html div onClick: (html jQuery this attributeAt: 'title' put: (html jQuery
ajax loadValue: [ :s | s nextPutAll: #{test -> 1}]))

I've seen JQAjax>>#callback:json: but I can't wrap my head around how this
works.
><


On Tue, Oct 6, 2009 at 2:31 PM, Lukas Renggli <renggli at gmail.com> wrote:

> 2009/10/6 Richard Durr <richard.durr at googlemail.com>:
> > Hello,
> > I'd like to set the background-color of a parent element that contains a
> > selectbox using ajax without replacing the whole. I tried to load the
> value
> > through "ajax html:" like so:
> > html select
> >   onChange: (html jQuery ajax serialize: html jQuery this) ,
> >     ((html jQuery this parent: '.model' ) cssAt: 'background-color' put:
> > (html jQuery ajax html: [:r | r text: 'red' ]));
> >   callback: [ :value | aModelObject color: value key. ];
> >   selected: selectedColor;
> >   addAll: colors;
> >   labels: [:item | item value.].
>
> The use of
>
>   html jQuery this parent: '.model'
>
> is a bit strange, because this only returns the *direct* parents that
> have the class .model. You might easily end up with an empty result
> set and simply nothing happens. It might not be a problem in your
> case, but it would be more intention revealing if you used #closest:
> instead of #parent:
>
> The expression
>
>   html jQuery ajax html: [:r | r text: 'red' ]
>
> does not return the requested value, but the AJAX object itself.
> Furthermore AJAX calls are asynchronous, so they immediately return.
>
> Something along the following lines should work:
>
>   (html jQuery this closest: '.model') cssAt: 'background-color' put: 'red'
>
> If you want to go through a server round-trip you could integrate the
> change into the AJAX call you do to serialize the value. What about
> something along ...
>
>   html jQuery ajax
>        serialize: html jQuery this;
>        script: [ :script | script add: ((script jQuery: '.model')
> cssAt: 'background-color' put: currentColor) ]
>
> Cheers,
> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
> _______________________________________________
> 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/20091007/31fa8841/attachment-0001.htm


More information about the seaside mailing list