-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Why this work for texbox
<zk xmlns:w="client">
<textbox id="txt" value="test" onChange='alert("client updated:"+ event.getValue());' />
<button id="test" label="click me to change value and updateChange_" w:onClick="var t = zk.Widget.$('$txt');t.$n().value=('test2');t.updateChange_();" />
</zk>
and this don't work for datebox ?
<zk xmlns:w="client">
<datebox id="txt" onChange='alert("client updated:"+ event.getValue());' />
<button id="test" label="click me to change value and updateChange_" w:onClick="var t = zk.Widget.$('$txt');t.$n().value=(new Date());t.updateChange_();" />
</zk>
I will prefer to use widget api directly(method start/end with _
are not suggested to use since it is for internal only), use setValue(val)
and fireOnChange()
, please refer to setValue API here
<zk xmlns:w="client">
<textbox id="txt" value="test"
onChange='alert("client updated:"+ event.getValue());' />
<button id="test" label="click me to change value and updateChange_"
w:onClick="var t = zk.Widget.$('$txt');t.setValue('test2');t.fireOnChange()" />
<datebox
id="dbx"
onChange='alert("client updated:"+ event.getValue());' />
<button
id="test2" label="click me to change value and updateChange_"
w:onClick="var t = zk.Widget.$('$dbx');t.setValue(new Date());t.fireOnChange()" />
</zk>
Because datebox has a different DOM structure, you would need to change t.$n().value
to t.$n('real').value
to access the date string.
<zk xmlns:w="client">
<datebox
id="dbx"
onChange='alert("client updated:"+ event.getValue());' />
<button
id="test" label="click me to change value and updateChange_"
w:onClick="var t = zk.Widget.$('$dbx');t.$n('real').value=(new Date());t.updateChange_();" />
</zk>
Thank you neillee. I changed the code and the datebox (t.setValue(new Date());) now is valued, but unfortunately the onchange event is not yet fired. What's wrong?
conversf ( 2013-01-23 07:32:58 +0800 )editThank you very much dennis. Now everything works.
conversf ( 2013-01-23 13:17:08 +0800 )edit