[Seaside] Q on "html select" and how to get selected item in an Ajax callback

Bob Arning arning at charm.net
Thu Oct 13 14:16:12 UTC 2011


We had a very similar question on 28-29 Sept (see "Using the select 
tag"). The end result was something like:

(html select)
     list: self genders;
     selected: self contact gender;
     enabled: [:ea | ea notNil];
     labels: [:ea | ea ifNil: ['---'] ifNotNil: [ea printableVersion]];
     callback: [:value | self contact gender: value].

Cheers,
Bob

On 10/13/11 10:03 AM, squeakman wrote:
> Hello All,
>
> Is there a way to get the selectedItem when the Ajax callback is 
> triggered in an html select?
>
> The following code snippet works for me but I think there must be a 
> better way.
>
> (html select)
>   id: 'stocksList';
>   list: self listOfStocks;
>   onClick: (html scriptaculous request
>               callback: [:i |self selectedStockIndex: i asNumber + 1.]
>               value: self jsForGetSelectedIndex).
>
>
> Note that I am using the call:value: method.
>
> The "self jsForGetSelectedIndex" returns the javascript code that gets 
> the selected index.
>
> In the callback: I use this returned value to figure out which item 
> was selected.
>
> Is there a better way to do this?
>
> Thanks,
> Frank
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20111013/97ec761f/attachment.htm


More information about the seaside mailing list