checkbox callbacks

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

checkbox callbacks

laza
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
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: checkbox callbacks

Robert Sirois
Two things:

You're calling #serializeForm, which serializes the nearest form, which would therefore serialize all elements in the form.

Look at JQAjax #serializeThis comment. Checkboxes require a #serializeThisWithHidden call.

RS

> From: [hidden email]

> Date: Sat, 24 Sep 2011 19:31:14 +0200
> To: [hidden email]
> Subject: [Seaside] checkbox callbacks
>
> 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
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: checkbox callbacks

Lukas Renggli
In reply to this post by laza
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ć <[hidden email]> 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
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>

--
Lukas Renggli
www.lukas-renggli.ch

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: checkbox callbacks

laza
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 <[hidden email]>:

> 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ć <[hidden email]>
> 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
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>
> --
> Lukas Renggli
> www.lukas-renggli.ch
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: checkbox callbacks

laza
#serializeThisWithHidden works nicly to update the internal state, but
I can't wrap my mind around on how to update the checkboxes.
Now the following obviously won't work but hopefully reveals my intentions:

renderContentOn: html
        html form: [
                html checkbox
                        onChange: (html jQuery ajax serializeThisWithHidden);
                        value: self isChecked;
                        callback: [:value | self check: value. self check2: value].
                html text: 'Check me'.
                html checkbox
                        onChange: (html jQuery ajax serializeThisWithHidden);
                        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?

Alex

2011/9/26 Alexander Lazarević <[hidden email]>:

> 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 <[hidden email]>:
>> 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ć <[hidden email]>
>> 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
>>> [hidden email]
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>>
>> --
>> Lukas Renggli
>> www.lukas-renggli.ch
>>
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>>
>
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: checkbox callbacks

Lukas Renggli
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ć <[hidden email]>:
>> 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 <[hidden email]>:
>>> 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ć <[hidden email]>
>>> 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
>>>> [hidden email]
>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>>
>>>
>>> --
>>> Lukas Renggli
>>> www.lukas-renggli.ch
>>>
>>> _______________________________________________
>>> seaside mailing list
>>> [hidden email]
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>>>
>>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>



--
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: checkbox callbacks

Lukas Renggli
On 26 September 2011 13:39, Lukas Renggli <[hidden email]> wrote:

> 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 ])

Sorry, this is a bit buggy. You don't want to re-render the div here,
just what is inside. So better extract the inner part to a separate
method.

>
>>                        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ć <[hidden email]>:
>>> 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 <[hidden email]>:
>>>> 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ć <[hidden email]>
>>>> 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
>>>>> [hidden email]
>>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>>>
>>>>
>>>> --
>>>> Lukas Renggli
>>>> www.lukas-renggli.ch
>>>>
>>>> _______________________________________________
>>>> seaside mailing list
>>>> [hidden email]
>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>>
>>>>
>>>
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>
>
>
> --
> Lukas Renggli
> www.lukas-renggli.ch
>



--
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: checkbox callbacks

laza
Sweet! That works like a charm. Thanks

Alex

2011/9/26 Lukas Renggli <[hidden email]>:

> On 26 September 2011 13:39, Lukas Renggli <[hidden email]> wrote:
>> 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 ])
>
> Sorry, this is a bit buggy. You don't want to re-render the div here,
> just what is inside. So better extract the inner part to a separate
> method.
>
>>
>>>                        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ć <[hidden email]>:
>>>> 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 <[hidden email]>:
>>>>> 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ć <[hidden email]>
>>>>> 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
>>>>>> [hidden email]
>>>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>>>>
>>>>>
>>>>> --
>>>>> Lukas Renggli
>>>>> www.lukas-renggli.ch
>>>>>
>>>>> _______________________________________________
>>>>> seaside mailing list
>>>>> [hidden email]
>>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>>>
>>>>>
>>>>
>>> _______________________________________________
>>> seaside mailing list
>>> [hidden email]
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>>
>>
>>
>> --
>> Lukas Renggli
>> www.lukas-renggli.ch
>>
>
>
>
> --
> Lukas Renggli
> www.lukas-renggli.ch
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: checkbox callbacks

laza
Now I need to find a solution for session timeouts. If a session times out and the user clicks on a checkbox nothing happens (obviously).
How can I redirect that request to act as an initial request for the root component (so to say)?

Thanks,
 Alex

2011/9/26 Alexander Lazarević <[hidden email]>
Sweet! That works like a charm. Thanks

Alex

2011/9/26 Lukas Renggli <[hidden email]>:
> On 26 September <a href="tel:2011%2013" value="+49201113">2011 13:39, Lukas Renggli <[hidden email]> wrote:
>> 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 ])
>
> Sorry, this is a bit buggy. You don't want to re-render the div here,
> just what is inside. So better extract the inner part to a separate
> method.
>
>>
>>>                        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ć <[hidden email]>:
>>>> 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 <[hidden email]>:
>>>>> 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ć <[hidden email]>
>>>>> 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
>>>>>> [hidden email]
>>>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>>>>
>>>>>
>>>>> --
>>>>> Lukas Renggli
>>>>> www.lukas-renggli.ch
>>>>>
>>>>> _______________________________________________
>>>>> seaside mailing list
>>>>> [hidden email]
>>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>>>
>>>>>
>>>>
>>> _______________________________________________
>>> seaside mailing list
>>> [hidden email]
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>>
>>
>>
>> --
>> Lukas Renggli
>> www.lukas-renggli.ch
>>
>
>
>
> --
> Lukas Renggli
> www.lukas-renggli.ch
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: checkbox callbacks

Lukas Renggli
Yes, see what JQAllFunctionalTests>>#renderTimeoutOn: is doing.

Or search this mailing list, many solutions have been posted and discussed.

Lukas

On 18 October 2011 12:59, Alexander Lazarević <[hidden email]> wrote:

> Now I need to find a solution for session timeouts. If a session times out
> and the user clicks on a checkbox nothing happens (obviously).
> How can I redirect that request to act as an initial request for the root
> component (so to say)?
>
> Thanks,
>  Alex
>
> 2011/9/26 Alexander Lazarević <[hidden email]>
>>
>> Sweet! That works like a charm. Thanks
>>
>> Alex
>>
>> 2011/9/26 Lukas Renggli <[hidden email]>:
>> > On 26 September 2011 13:39, Lukas Renggli <[hidden email]> wrote:
>> >> 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 ])
>> >
>> > Sorry, this is a bit buggy. You don't want to re-render the div here,
>> > just what is inside. So better extract the inner part to a separate
>> > method.
>> >
>> >>
>> >>>                        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ć <[hidden email]>:
>> >>>> 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 <[hidden email]>:
>> >>>>> 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ć
>> >>>>> <[hidden email]>
>> >>>>> 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
>> >>>>>> [hidden email]
>> >>>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> >>>>>>
>> >>>>>
>> >>>>> --
>> >>>>> Lukas Renggli
>> >>>>> www.lukas-renggli.ch
>> >>>>>
>> >>>>> _______________________________________________
>> >>>>> seaside mailing list
>> >>>>> [hidden email]
>> >>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> >>>>>
>> >>>>>
>> >>>>
>> >>> _______________________________________________
>> >>> seaside mailing list
>> >>> [hidden email]
>> >>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> Lukas Renggli
>> >> www.lukas-renggli.ch
>> >>
>> >
>> >
>> >
>> > --
>> > Lukas Renggli
>> > www.lukas-renggli.ch
>> > _______________________________________________
>> > seaside mailing list
>> > [hidden email]
>> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> >
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>



--
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: checkbox callbacks

Boris Popov, DeepCove Labs (SNN)
In reply to this post by laza

http://api.jquery.com/jQuery.ajaxSetup/

 

or,

 

jQuery.ajaxSetup({

  "error":function(jqXHR,textStatus,errorThrown){

    if (jqXHR.status === 403) {window.location="/online?expired";}

});

 

or,

 

JQAjaxSetup>>onError:

 

HTH,

 

-Boris

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Alexander Lazarevic
Sent: Tuesday, October 18, 2011 7:00 AM
To: Seaside - general discussion
Subject: Re: [Seaside] checkbox callbacks

 

Now I need to find a solution for session timeouts. If a session times out and the user clicks on a checkbox nothing happens (obviously).
How can I redirect that request to act as an initial request for the root component (so to say)?

Thanks,
 Alex

2011/9/26 Alexander Lazarević <[hidden email]>

Sweet! That works like a charm. Thanks

Alex

2011/9/26 Lukas Renggli <[hidden email]>:

> On 26 September <a href="tel:2011%2013">2011 13:39, Lukas Renggli <[hidden email]> wrote:


>> 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 ])
>
> Sorry, this is a bit buggy. You don't want to re-render the div here,
> just what is inside. So better extract the inner part to a separate
> method.
>
>>
>>>                        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ć <[hidden email]>:
>>>> 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 <[hidden email]>:
>>>>> 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ć <[hidden email]>
>>>>> 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
>>>>>> [hidden email]
>>>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>>>>
>>>>>
>>>>> --
>>>>> Lukas Renggli
>>>>> www.lukas-renggli.ch
>>>>>
>>>>> _______________________________________________
>>>>> seaside mailing list
>>>>> [hidden email]
>>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>>>
>>>>>
>>>>
>>> _______________________________________________
>>> seaside mailing list
>>> [hidden email]
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>>
>>
>>
>> --
>> Lukas Renggli
>> www.lukas-renggli.ch
>>
>
>
>
> --
> Lukas Renggli
> www.lukas-renggli.ch
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>

 

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: checkbox callbacks

laza
In reply to this post by Lukas Renggli
Thanks, I've decided to go along with [1].

Alex

[1] http://www.tonyfleig.com/smallthoughts/blog/avoidingsessiontimeouts
2011/10/18 Lukas Renggli <[hidden email]>
Yes, see what JQAllFunctionalTests>>#renderTimeoutOn: is doing.

Or search this mailing list, many solutions have been posted and discussed.

Lukas

On 18 October <a href="tel:2011%2012" value="+49201112">2011 12:59, Alexander Lazarević <[hidden email]> wrote:
> Now I need to find a solution for session timeouts. If a session times out
> and the user clicks on a checkbox nothing happens (obviously).
> How can I redirect that request to act as an initial request for the root
> component (so to say)?
>
> Thanks,
>  Alex
>
> 2011/9/26 Alexander Lazarević <[hidden email]>
>>
>> Sweet! That works like a charm. Thanks
>>
>> Alex
>>
>> 2011/9/26 Lukas Renggli <[hidden email]>:
>> > On 26 September <a href="tel:2011%2013" value="+49201113">2011 13:39, Lukas Renggli <[hidden email]> wrote:
>> >> 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 ])
>> >
>> > Sorry, this is a bit buggy. You don't want to re-render the div here,
>> > just what is inside. So better extract the inner part to a separate
>> > method.
>> >
>> >>
>> >>>                        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ć <[hidden email]>:
>> >>>> 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 <[hidden email]>:
>> >>>>> 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ć
>> >>>>> <[hidden email]>
>> >>>>> 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
>> >>>>>> [hidden email]
>> >>>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> >>>>>>
>> >>>>>
>> >>>>> --
>> >>>>> Lukas Renggli
>> >>>>> www.lukas-renggli.ch
>> >>>>>
>> >>>>> _______________________________________________
>> >>>>> seaside mailing list
>> >>>>> [hidden email]
>> >>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> >>>>>
>> >>>>>
>> >>>>
>> >>> _______________________________________________
>> >>> seaside mailing list
>> >>> [hidden email]
>> >>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> Lukas Renggli
>> >> www.lukas-renggli.ch
>> >>
>> >
>> >
>> >
>> > --
>> > Lukas Renggli
>> > www.lukas-renggli.ch
>> > _______________________________________________
>> > seaside mailing list
>> > [hidden email]
>> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> >
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>



--
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside