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.]. But this does not seem to work, since nothing is happening.
Can anybody help? RD _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
2009/10/6 Richard Durr <[hidden email]>:
> 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 [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
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 <[hidden email]> wrote: 2009/10/6 Richard Durr <[hidden email]>: _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
> 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}])) No, this is not possible. Ajax calls do not have a return value, unfortunately there are no continuations in Javascript. You can achieve the same the other way round though: html div onClick: (html jQuery ajax script: [ :s | s add: (s jQuery this attributeAt: 'title' put: #test -> 1) ]); with: 'Click me' Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Interessting, thank you very much! :)
On Mon, Oct 12, 2009 at 8:32 AM, Lukas Renggli <[hidden email]> wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |