-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello to all, i'm a newbie in zk and i getting started with the MVVM tutorial: books.zkoss.org/wiki/ZKGettingStarted/GetZKUpandRunningwithMVVM To experiment, I put the event onchanging in the textbox, but when i put a text in a textbox the model of a listbox does not update. If i use onchange, the listbox is update only when unset focus (onblur). how do you?
<hbox align="center">
Cerca:
<textbox value="@bind(vm.keyword)" onChanging="@command('search')" />
<button onClick="@command('search')" label="Search" image="/img/search.png" />
</hbox>
<!-- CAR LIST -->
<listbox model="@bind(vm.carList)" selectedItem="@bind(vm.selectedCar)" height="160px" emptyMessage="No car found in the result">
<listhead>
<listheader label="model" />
<listheader label="price" />
<listheader label="make" />
</listhead>
<template name="model">
<listitem>
<listcell label="@bind(each.model)"></listcell>
<listcell label="@bind(each.price)"></listcell>
<listcell label="@bind(each.make)"></listcell>
</listitem>
</template>
</listbox>
ViewModel
@Command
@NotifyChange("carList") //ZK can reload the changed property for us after it invokes this method.
public void search(){
carList = carService.search(keyword);
}
//get e set keyword public void setKeyword(String keyword) { this.keyword = keyword; } public String getKeyword() { return keyword; }
public List<Car> getCarList(){
return carList;
}
If you want that the textbox updates with the onChanging event, please add
instant=true
In the textbox.
Greetz chill.
Asked: 2015-12-29 20:46:44 +0800
Seen: 61 times
Last updated: Dec 30 '15