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

yennor
10 2

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 retag edit

Sort by » oldest newest most voted

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)

[hide preview]