0

Render and binding with command global-command

asked 2017-08-10 16:35:02 +0800

ajamardo gravatar image ajamardo
41 4

I have this in my template <apply selected="@bind(vmApp.selected)" templateURI="/app/thg/equipments/equipments/EquipmentClass.zul" /

And then, in a button, I have:

<button zclass="z-button-list" label="Change" disabled="@load(empty vmApp.type or vmApp.upserting)" onClick="@command('update') @global-command('update')" />

Where the command update makes the vmApp.selected to change, and the global-command set some variables in the template. My problem is that the template is rendered after the global-command is executed. IS there any way to do this?

delete flag offensive retag edit

Comments

I don't quite understand the scenario. Please provide a running example on https://zkfiddle.org. This will help to get a useful answer quickly.

cor3000 ( 2017-08-11 03:19:22 +0800 )edit

Hi again. I reused the fiddle you sent me for this. In this fiddle, when you click in 'load' button, it should show the textbox with disabled=true, but it doesn't http://zkfiddle.org/sample/3s936ku/11-Bind-command-and-global-command

ajamardo ( 2017-08-11 06:32:43 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-08-11 07:37:00 +0800

cor3000 gravatar image cor3000
6280 2 7

updated 2017-08-11 07:40:27 +0800

I updated the fiddle example following the same pattern, pass in a parameter edit="@load(outerVM.edit)" and use it in the InnerVM

http://zkfiddle.org/sample/3s936ku/12-Bind-command-and-global-command

Once you reach a stage where you think you have too many parameters passed into the template you can just send a more complex object containing both the object to show/edit and additional flags like editable, showDetails ...

global-commands just make your application hard to follow especially in this case where one ViewModel triggers creation of a nested ViewModel ... using parameters feels more natural just like calling a method with arguments -> call a template with parameters.

global commands should be used rarely to send commands between otherwise unrelated parts of your UI

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: 2017-08-10 16:35:02 +0800

Seen: 25 times

Last updated: Aug 11 '17

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