[Seaside] onClick notifications for check box or multiSelect

Paul DeBruicker pdebruic at gmail.com
Wed May 11 10:53:44 UTC 2011


On 05/10/2011 09:24 PM, seaside-request at lists.squeakfoundation.org wrote:
> On Tuesday, 10 May 2011, <jsavidge at texas.net> wrote:
>> >  Greetings,
>> >
>> >  Despite trying to follow the suggestions I have seen in the discussions and in
>> >  the documentation, I can’t seem to get onClick notifications to work on
>> >  checkbox(s) or multiSelect.
>> >
>> >  My goal is to present the user with a list of selections, and when they click
>> >  on one of the items in the list, I want to refresh a secondary list with data
>> >  that is related to selection they made in the first list.

Something similar to what I wrote below is what has worked for me in the 
past using Pharo/Gemstone & Seaside 3.  When using checkboxes you 
probably want onClick rather than onChange because IE does not register 
the change until the checkbox loses focus. I haven't tried a 
multiselect.  And there is likely a better/cleaner way to do this.


renderUpdatingCheckbox:html
|id |

html checkbox
	id: (id := html nextId);
	value: cbox;
	onClick:
		((html jQuery ajax)
			serializeThisWithHidden;
			script: [ :s | s << (s jQuery id: 'target-div') load: [ :h | self 
renderTarget: h ] ]);
	callback: [ :value | cbox:=value ].

html label
	for: id;
	with: 'checkbox test'.
html div
	id:'target-div';
	with:[self renderTarget: html].


renderTarget: html
  cbox ifTrue:[html render:'Box is checked'] ifFalse:[html render:'Box 
is not checked']


If you want to test the above you'd need an ivar in your component named 
#cbox.  Also I'm not sure about this but I thought that if you use 
labels rather than the trailing #with: your user can click the entire 
label to trigger the change in the check box.

Paul


More information about the seaside mailing list