-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
How could I get a value of ZK Component to use it in javascript code which uses ajax Request? I need value of a ZK Component which will be a param in the ajax Request.
In my code:
I'd like get value of param 'tags' from ZK Component.
Thanks all
hi oliver
look the follows links:
http://books.zkoss.org/wiki/Small_Talks/2010/April/Client_Side_Programming
http://books.zkoss.org/wiki/ZK_Client-side_Reference
and codes below:
<zk xmlns:w="client">
<label id="tb" width="250px" value="hello" >
<custom-attributes org.zkoss.zk.ui.updateByClient="true"/>
</label>
<button label="chage at client-side">
<attribute w:name="onClick"><![CDATA[
var tb = zk.Widget.$(jq('$tb')),
val = 'world';
tb.setValue(val);
tb.smartUpdate('value', val);
]]></attribute>
</button>
<button label="get at server-side" onClick="alert(tb.value)"/>
</zk>
package j173cqqt$v1;import org.zkoss.zk.ui.*;
import org.zkoss.zk.ui.event.*;
import org.zkoss.zk.ui.util.*;
import org.zkoss.zk.ui.ext.*;
import org.zkoss.zk.au.*;
import org.zkoss.zk.au.out.*;
import org.zkoss.zul.*;public class TestComposer extends GenericForwardComposer{
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);}
public void onClick$btn(Event e) throws InterruptedException{
Messagebox.show("Hi btn");
}
}
<zk>
<script>
function testjq(widget){
jq(widget).attr('disabled', true);
}
</script>
<window border="normal" title="hello" apply="j173cqqt$v1.TestComposer" xlmns:w="client">
<div>Welcome to ZK Fiddle , run it right now!</div>
<button label="Click Me To disable textbox using jquery" w:onClick="testjq(jq('$tb'))"/>
<textbox id="tb"/>
</window>
</zk>
i hope that help you...
Thanks for the examples!
I get the solution with 'Clients.evalJavaScript(jsMethod)' which calls the jsMethod in the client.
Asked: 2012-03-08 10:15:36 +0800
Seen: 274 times
Last updated: Mar 09 '12