Re: Suggested extension for WASelectTag

"[email protected]" <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.squeak.seaside
Message-ID <[email protected]>
Hi Johan,

so #dispatchCallback was my missing piece... Thanks!

I agree with your preference, for cases where you want to iterate over 
myItems. This sure would be a nicer API than what we have now.

Joachim




Am 03.07.17 um 09:19 schrieb Johan Brichau:
> Hi guys,
>
> I would prefer that Seaside is able to do this:
>
> html select
>        callback: …;
>        with:[
>            myItems do:[:anItem |
>          html option
>        attributeAt: … put: …;
> value: anItem ] ]
>
> Right now, you must do it like this (i.e. add a callback for each option):
>
> html select
>        dispatchCallback;
>        with:[
>            myItems do:[:anItem |
>          html option
>      attributeAt: … put: …;
>                         callback: [ …. ]
> value: anItem ] ]
>
> cheers,
> Johan
>
>> On 3 Jul 2017, at 02:23, Mariano Martinez Peck <[email protected] 
>> <mailto:[email protected]>> wrote:
>>
>>
>>
>> On Sat, Jul 1, 2017 at 2:24 AM,[email protected] 
>> <mailto:[email protected]><[email protected] 
>> <mailto:[email protected]>>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 <http://marianopeck.wordpress.com/>
>> _______________________________________________
>> seaside mailing list
>> [email protected] 
>> <mailto:[email protected]>
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
>
> _______________________________________________
> seaside mailing list
> [email protected]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


-- 
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel          mailto:[email protected]
Fliederweg 1                         http://www.objektfabrik.de
D-71640 Ludwigsburg                  http://joachimtuchel.wordpress.com
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1

_______________________________________________
seaside mailing list
[email protected]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.