[Seaside] liveUpdate checkboxes

Yar Hwee Boon hboon at motionobj.com
Fri Aug 12 17:41:40 CEST 2005


On 12-Aug-05, at PM 05:14, Bany, Michel wrote:

>
> Another question : if I am not mistaken, there is no live update
> possible
> for checkboxes, is it ? I tried the things below, but it does not 
> always
> work,
> any idea ?
>
> Michel.
>
>
> checkboxWithValue: aBoolean callback: callbackBlock liveCallback:
> liveBlock
> 	| uri id |
> 	id := self ensureId.
> 	self checkboxWithValue: aBoolean callback: callbackBlock.
> 	uri := self urlForLiveRequest: [:v :h | liveBlock value: v =
> 'true' value: h].
> 	self script: 'document.getElementById(' , id printString ,
> ').onclick = liveCheck(' , id printString , ',' , uri asString
> printString , ')'.
>
>
> function liveCheck(id, uri)
> {
> 	function constructUri()
> 	{
> 		return addParameter(uri, "s",
> document.getElementById(id).checked);
> 	}
> 	return liveUpdater(constructUri);
> }

Seems that changing the event handler from onclick to onchange makes it 
work. At least when I test it using mac Firefox.

============
renderContentOn: html
	x
		ifNil: [x := 1].
	html
		form: [html
				checkboxWithValue: false
				callback: [self halt]
				liveCallback: [:v :h | h
						divNamed: 'ele'
						with: [x := x + 1.
							h text: x asString , v asString]]].
	html divNamed: 'ele' with: 'xxx'
============

--
HweeBoon
http://motionobj.com/blog/
MotionObj
(65) 6764-9774



More information about the Seaside mailing list