Callbacks on collection tags

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

Callbacks on collection tags

Esteban A. Maringolo
I'm having an issue with the use of collection tags (i.e. unordered
list), and Scriptaculous updater.

I can't specify and updater directly to the unorderedList.

For example:

renderContentOn: html
    html unorderedList
        list: myListOfItems
        onClick: (
                html updater
                 id: containerId;
                 callback: [:r | self renderHandlerOn: r]);
        callback: [:x | self onItemSelected: x].

In the previous example, the unordered list callback block, when
executed, knows the "selected" item.
But there's no way to know it in the updater block.

The only way I found to handle this, is to build the list explicitly:

    html unorderedList
        with: [
                myListOfItems do: [:each |
                html listItem
                        onClick: (
                                html updater
                                 id: containerId;
                                 callback: [:r | self renderHandlerOf: each on: r]);
                callback: [:x | self onItemSelected: x]
                ]
        ].


But perhaps I'm missing something.

Best regards,

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

Re: Callbacks on collection tags

Lukas Renggli
> In the previous example, the unordered list callback block, when
> executed, knows the "selected" item.
> But there's no way to know it in the updater block.

In the above code you define the onClick action on the list, therefor
you only knowledge is that the user clicked in the area of the ul-tag.

Fore sake of correctness: It is possible to find out what element was
originally clicked by looking at the JavaScript event object. However
this is not easily feasible (yet) by only writing Smalltalk code.

Cheers,
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: Callbacks on collection tags

Esteban A. Maringolo
Hi Lukas:

On Feb 4, 2008 3:47 PM, Lukas Renggli <[hidden email]> wrote:
> > In the previous example, the unordered list callback block, when
> > executed, knows the "selected" item.
> > But there's no way to know it in the updater block.
>
> In the above code you define the onClick action on the list, therefor
> you only knowledge is that the user clicked in the area of the ul-tag.

Yes, you're right. Then it's ok it works that way, it is homogeneous
with the rest.

> Fore sake of correctness: It is possible to find out what element was
> originally clicked by looking at the JavaScript event object. However
> this is not easily feasible (yet) by only writing Smalltalk code.

Ok, then it is still convenient to render the list items manually.

Thanks.

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