Seaside + Scriptaculous: updating checkbox value

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

Seaside + Scriptaculous: updating checkbox value

Leandro Pérez
Hi,
I'm trying to do something like this:
I have a checkbox displaying the state of a door, i.e. open->checked, closed->unchecked. When clicking the checkbox, the door must be closed or opened (a server side model object representing the door is asked to be closed/opened via ajax). The thing is that according to different variables evaluated on the model on the server at the time the door is asked to be closed/opened, it is effectively closed/opened or not, and therefore the checkbox on the browser might be inconsistent with the real state of the door after the petition.
My problem is, I can't find the way to update the value of the checkbox without refreshing the whole page, i'm currently trying something like this:
renderContentOn: html
...
        html form id:'myForm'; with: [
                (html checkbox)
                id: 'door_checkbox_' , doorNumber printString;
                value: (myModelDoorManager isDoorClosed: doorNumber);
                onClick: (html evaluator callback:
                        [:script |
                                   myModelDoorManager operateOnDoor: doorNumber.

                                   ..."here! the checkbox value should be updated to the proper one obtained from a door model object on the server side"
                                "the value is obtained from the model object in the server side using:
                                myModelDoorManager isDoorClosed: doorNumber"
                        ]
                ]


i'm currently using
        VisualWorks NonCommercial, 7.5
        Seaside2.7b1
        Scriptaculous2.6-mb.8

Regards,
Leandro
Reply | Threaded
Open this post in threaded view
|

Re: Seaside + Scriptaculous: updating checkbox value

Lukas Renggli
You need to put a div around the checkbox, give it an id and update
that div. This will be simpler in the upcoming version of
Scriptaculous, for now something like that should work:

renderContentOn: html
   html form: [
      html div id: 'checkbox'; with: [
         self renderCheckboxOn: html ] ]

renderCheckboxOn: html
   html checkbox
       value: ...;
       onClick: (html updater
         id: 'checkbox';
         callback: [ :r | self renderCheckboxOn: r ])

Lukas

--
Lukas Renggli
http://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: Seaside + Scriptaculous: updating checkbox value

Leandro Pérez
Thanks a lot Lukas, that worked just fine!
Would you recomend me some documentation sources, tutorials, papers, books etc.. on scriptaculous+seaside?

Lukas Renggli wrote
You need to put a div around the checkbox, give it an id and update
that div. This will be simpler in the upcoming version of
Scriptaculous, for now something like that should work:

renderContentOn: html
   html form: [
      html div id: 'checkbox'; with: [
         self renderCheckboxOn: html ] ]

renderCheckboxOn: html
   html checkbox
       value: ...;
       onClick: (html updater
         id: 'checkbox';
         callback: [ :r | self renderCheckboxOn: r ])

Lukas

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

Re: Seaside + Scriptaculous: updating checkbox value

Lukas Renggli
> Thanks a lot Lukas, that worked just fine!
> Would you recomend me some documentation sources, tutorials, papers, books
> etc.. on scriptaculous+seaside?

Unfortunately there is almost no documentation about Seaside+Scriptaculous.

I am sure you noticed the tests and examples that come with the
framework. This is probably the most up-to-date and complete source of
examples [1]. Then there are some blogs posts [2, 3] and some
presentations of myself [4].

It is fairly straight forward to do any Prototypes [5] (the JavaScript
framework script.aculo.us is built upon) and script.aculo.us [6]
tutorial and use it together with Seaside. Almost for any part of the
Javascript frameworks has a Smalltalk counterpart that can be used in
an 'obvious' way. There is also relevant amount of documentation in
the classes and methods of the Smalltalk code.

Hope this helps,
Lukas

[1] http://scriptaculous.seasidehosting.st
[2] http://onsmalltalk.com
[3] http://objectcentric.wordpress.com
[4] http://www.lukas-renggli.ch/smalltalk/seaside
[5] http://script.aculo.us
[6] http://prototypejs.org/

--
Lukas Renggli
http://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: Seaside + Scriptaculous: updating checkbox value

Leandro Pérez
Great!!   it will surely help

thanks again

Leandro


Lukas Renggli wrote
> Thanks a lot Lukas, that worked just fine!
> Would you recomend me some documentation sources, tutorials, papers, books
> etc.. on scriptaculous+seaside?

Unfortunately there is almost no documentation about Seaside+Scriptaculous.

I am sure you noticed the tests and examples that come with the
framework. This is probably the most up-to-date and complete source of
examples [1]. Then there are some blogs posts [2, 3] and some
presentations of myself [4].

It is fairly straight forward to do any Prototypes [5] (the JavaScript
framework script.aculo.us is built upon) and script.aculo.us [6]
tutorial and use it together with Seaside. Almost for any part of the
Javascript frameworks has a Smalltalk counterpart that can be used in
an 'obvious' way. There is also relevant amount of documentation in
the classes and methods of the Smalltalk code.

Hope this helps,
Lukas

[1] http://scriptaculous.seasidehosting.st
[2] http://onsmalltalk.com
[3] http://objectcentric.wordpress.com
[4] http://www.lukas-renggli.ch/smalltalk/seaside
[5] http://script.aculo.us
[6] http://prototypejs.org/

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
Seaside@lists.squeakfoundation.org
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside