[Seaside] Suggested extension for WASelectTag

Mariano Martinez Peck marianopeck at gmail.com
Mon Jul 3 00:23:07 UTC 2017


On Sat, Jul 1, 2017 at 2:24 AM, jtuchel at objektfabrik.de <
jtuchel at objektfabrik.de> wrote:

> Hi,
>
>
> I needed a way to add an attribute of each option in a select list,
> because Seaside uses the value attribute for its server side callback.
>
> The reason was I wanted to do something on the browser side
> onChange/onKeyUp based on some business values.
>
>
> Here is what I changed in WASelectTag:
>
> * added inst var: itemConfigBlock with getter and setter
>
> * changed #renderListItemLabelled: to
>
>
> renderListItem: anObject labelled: aString
>
>     | option |
>
>     option := canvas option.
>     self hasCallback ifTrue: [option value: (self valueFor: anObject)].
>     titleBlock isNil ifFalse: [option title: (self titleFor: anObject)].
>     itemConfigBlock ifNotNil: [:block | block value: option value:
> anObject].
>     option
>         selected: (self isSelected: anObject);
>         disabled: (self isEnabled: anObject) not;
>         with: aString
>
>
> And this is how you can use it:
>
>
> html select
>
>     items: MyListOfItems;
>
>     callback: [];
>
>     itemConfigBlock: [:option :anObject| option attrbibuteAt: 'data-value'
> put: anObject someValue asString].
>
>
> Was this available already and did I overlook it?
>
> Does this sound reasonable? Worth adding to Seaside?
>
>
>
Yes, I had to do exactly the same.


-- 
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/seaside/attachments/20170702/13ce2028/attachment.html>


More information about the seaside mailing list