WASelectTag - html select question

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

WASelectTag - html select question

Louis LaBrunda
Hi,

I'm new to both Seaside and html so this may be a dumb question but here
goes.  It seems that when one wants an html "select" (that will return the
selected item) and the list is a collection of Associations, the "value"
part of the "option" is generated by Seaside and the displayed list item is
the #value of the Association.  It would be nice if the "value" part of the
"option" was the #key of the Association.

I need to use some javascript to do something based upon the item selected.
It would be better if it could test the "value" part of the "option" which
it could do if the "value" was the #key.  But if Seaside generates the
"value", this isn't possible.  Instead I must use the index of the selected
item, which will work but must be maintained if the list changes.  There
may also be a way to test the displayed part of the selected item (I
haven't found how yet) but this also has a maintenance problem if the list
changes.

Lou
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com

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

Re: WASelectTag - html select question

Lukas Renggli
> I'm new to both Seaside and html so this may be a dumb question but here
> goes.  It seems that when one wants an html "select" (that will return the
> selected item) and the list is a collection of Associations, the "value"
> part of the "option" is generated by Seaside and the displayed list item is
> the #value of the Association.  It would be nice if the "value" part of the
> "option" was the #key of the Association.

Seaside takes care of the value attribute of option tags, similar as
it does with all other names on a page. This is to ensure uniqueness,
even if different components or multiple instances of the same
component are displayed at once.

If you really want to specify your own names/values and if you don't
need the Seaside callbacks on these elements, feel free to run your
own rendering along the following lines:

html select: [
   aDictionary keysAndVauesDo: [ :key :value |
       html option
           value: key;
           with: value ] ]

Generally it is a better idea to use CSS classes to identify different
kind of DOM elements from Javascript.

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: WASelectTag - html select question

Louis LaBrunda
Hi Lukas,

Thank you very much for the reply.

>> I'm new to both Seaside and html so this may be a dumb question but here
>> goes.  It seems that when one wants an html "select" (that will return the
>> selected item) and the list is a collection of Associations, the "value"
>> part of the "option" is generated by Seaside and the displayed list item is
>> the #value of the Association.  It would be nice if the "value" part of the
>> "option" was the #key of the Association.

>Seaside takes care of the value attribute of option tags, similar as
>it does with all other names on a page. This is to ensure uniqueness,
>even if different components or multiple instances of the same
>component are displayed at once.

Yes, I see that Seaside is taking care of the values/names of the option
tags.  And, I do need to know which option was selected.  But, it seems to
me that only one name needs to be generated by Seaside for the select tag
so that the selected option (value part of option) can be returned.  It
seems the value attribute of option tags is being used by Seaside as a name
to return the selected option.

This may have more to do with what web browsers return than what Seaside
wants, I don't know?  I do realize that the options sent by Seaside don't
have to be Associations (although they match up nicely) and that may have a
lot to do with why Seaside always makes up values instead of sometimes
making them up and sometimes using the key of an Association.

>If you really want to specify your own names/values and if you don't
>need the Seaside callbacks on these elements, feel free to run your
>own rendering along the following lines:

>html select: [
>   aDictionary keysAndVauesDo: [ :key :value |
>       html option
>           value: key;
>           with: value ] ]
>
>Generally it is a better idea to use CSS classes to identify different
>kind of DOM elements from Javascript.
>Lukas

Thanks, Lou
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com

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