0

Problem invoking javascript using the 'action' attribute

asked 2011-08-23 04:51:53 +0800

cyiannoulis gravatar image cyiannoulis
1191 10

The following page is not rendered at all.

<zk>
	 <script type="text/JavaScript">
	   <![CDATA[ 
	     function doSomething(txtTest) {
	       	var value = txtTest.value;
	     }
	   ]]> 
	 </script>

	<window>
	
	 	<textbox id="txtTest" value="test" onChange="alert(self.getValue());" visible="false"/>
 		<button id="btnTest" label="call js function" action="onclick:doSomething(#{txtTest})"/>
	
        </window>
</zk>     

It seems that the

action="onclick:doSomething(#{txtTest})"
is causing the problem.
Any ideas?

Thank you all
/costas

delete flag offensive retag edit

6 Replies

Sort by ยป oldest newest

answered 2011-08-23 06:27:47 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

which zk version?

link publish delete flag offensive edit

answered 2011-08-23 07:12:05 +0800

cyiannoulis gravatar image cyiannoulis
1191 10

Hi terry,

zk 5.0.7

/costas

link publish delete flag offensive edit

answered 2011-08-23 08:38:19 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

Hmmm, i mean '<button action=' is not right

try it with the <button onClick=""

link publish delete flag offensive edit

answered 2011-08-23 09:14:39 +0800

cyiannoulis gravatar image cyiannoulis
1191 10

Thanks Stephan but no luck. I'm not sure what's the problem. Is the 'action' attribute deprecated?

/costas

link publish delete flag offensive edit

answered 2011-08-23 10:17:13 +0800

twiegand gravatar image twiegand
1807 3

Costas,

The action attribute in Client-Side Action is not depreciated but it has changed from how it worked in ZK 3.x.  Whereas in ZK 3 the action could take just about any onXXXX event, In ZK5 it is used mainly for "show", "hide", and "invalidate" operations.

For more information about CSA, you can go here.

If you want to call JavaScript from your zul there are a couple of ways that I do it:

Namespace

<zk xmlns:w="http://www.zkoss.org/2005/zk/client">
	<script>
		function test(){
			alert("Hello from JavaScript");
		}
	</script>
	<window>
		<button id="btnTest" label="call JS function" w:onClick="test()"/>
	</window>
</zk>

Java call

<zk>
	<script>
		function test(){
			alert("Hello from JavaScript");
		}
	</script>
	<window>
		<button id="btnTest" label="call JS function">
			<attribute name="onClick">
				String jsCommand = "test()";
				Clients.evalJavaScript(jsCommand);
			</attribute>
		</button>
	</window>
</zk>

Hope that helps,

Todd

link publish delete flag offensive edit

answered 2011-08-24 02:25:05 +0800

cyiannoulis gravatar image cyiannoulis
1191 10

Now it is clear.
Thank you very much for your time Todd.

/costas

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-08-23 04:51:53 +0800

Seen: 632 times

Last updated: Aug 24 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More