0

zk8 client side binding to a viewmodel command seems not to work

asked 2016-12-08 15:50:28 +0800

yennor gravatar image yennor
10 2

updated 2016-12-09 08:56:26 +0800

I'm using zk ce 8.0.2.2. I tried for a few hours to get the client side binding to a command in a viewmodel to work. I tried it out in several different ways in the zul file, at the end just in the java script debbuging console of chromium. I loaded an example to zkfiddle. I tried in several different ways to get it working, but I just needed to chose an example that would work in the fiddle.

http://zkfiddle.org/sample/3lsdr7g/5-zk-client-side-command-binding-test

when you click on the first normal zk button, the command gets called and the label changes its value.

When you click on the second button, which is a html button, with an onclick event, where the command should be called.

zkbind.$('$label').command('testcommand', {test: 'argh'});

But just nothing happens. not even an error message or anything. When I try to do it in the debugging console the command seems to work (no error message or anything), but the command at the server side never gets called.

Could anybody tell me what I'm doing wrong. For me it looks like I'm doing exactly the same as shown in the examples in the documentation.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-12-09 11:02:11 +0800

yennor gravatar image yennor
10 2

it took me hours to figure it out. But as it seems the problem is uncomplete documentation. You need to add the annotation "@ToServerCommand({...})" to the viemmodel class. It's neither mentioned in any of the smalltalks, nor in the documentation: http://books.zkoss.org/zk-mvvm-book/8.0/data_binding/client_binding_api.html (http://books.zkoss.org/zk-mvvm-book/8.0/databinding/clientbinding_api.html)

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2016-12-08 15:50:28 +0800

Seen: 30 times

Last updated: Dec 09 '16

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