[Seaside] checkbox callbacks
Lukas Renggli
renggli at gmail.com
Mon Sep 26 11:39:30 UTC 2011
It is probably the easiest if you just re-render that part of the
page. I suggest a refactorings along the following lines:
> renderContentOn: html
| id |
id := html nextId.
html div id: id; with: [
> html form: [
> html checkbox
> onChange: (html jQuery ajax serializeThisWithHidden);
You do replace the above line with:
onChange: ((html jQuery id: id) load serializeThisWithHidden;
html: [ :r | self renderContentOn: r ])
> value: self isChecked;
> callback: [:value | self check: value. self check2: value].
> html text: 'Check me'.
> html checkbox
> onChange: (html jQuery ajax serializeThisWithHidden);
And do the same here. Maybe extract it to a separate method so that
you can reuse it.
> value: self isChecked2;
> callback: [:value | self check2: value. self check: value not].
> html text: 'Check me 2'.
> ]
>
> So what's the best strategy to update the checkboxes reflecting the
> internal state?
] "close the div here"
Cheers,
Lukas
>
> Alex
>
> 2011/9/26 Alexander Lazarević <laza at blobworks.com>:
>> Robert and Lukas,
>>
>> I guess I still have some misconceptions when it comes to JS
>> callbacks, but thanks for helping me along. I had the idea that the
>> entire form gets serialized, but only the callbacks of changed
>> elements would trigger a onChange: event and then trigger the
>> callback.
>>
>> Alex
>>
>> 2011/9/24 Lukas Renggli <renggli at gmail.com>:
>>> Yes, you serialize the form which means it involves both checkboxes. On your
>>> scenario both callbacks should be triggered: the checked one with true, the
>>> unchecked with false.
>>>
>>> Btw, you do not need the IDs. For the AJAX just use (html jQuery ajax
>>> serializeForm). You don't want to load anything into the checkbox.
>>>
>>> Lukas
>>>
>>> On Saturday, 24 September 2011, Alexander Lazarević <laza at blobworks.com>
>>> wrote:
>>>> Hi!
>>>>
>>>> I'm using something like the following in my code:
>>>>
>>>> renderContentOn: html
>>>> | id |
>>>> html form: [
>>>> id := html nextId.
>>>> html checkbox
>>>> id: id;
>>>> onChange: (html jQuery id: id) load serializeForm;
>>>> value: self isChecked;
>>>> callback: [:value | value inspect].
>>>> html text: 'Check me'.
>>>> id := html nextId.
>>>> html checkbox
>>>> id: id;
>>>> onChange: (html jQuery id: id) load serializeForm;
>>>> value: self isChecked2;
>>>> callback: [:value | value inspect].
>>>> html text: 'Check me 2'.
>>>> ]
>>>>
>>>> I'm surprised to see that both callbacks get triggered even if I only
>>>> check one checkbox. Is this on purpose and expected? According to
>>>> Metacello I'm using Seaside 3.0.6
>>>>
>>>> Alex
>>>> _______________________________________________
>>>> seaside mailing list
>>>> seaside at lists.squeakfoundation.org
>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>>
>>>
>>> --
>>> Lukas Renggli
>>> www.lukas-renggli.ch
>>>
>>> _______________________________________________
>>> seaside mailing list
>>> seaside at lists.squeakfoundation.org
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>>>
>>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
--
Lukas Renggli
www.lukas-renggli.ch
More information about the seaside
mailing list