i'm new in ZK. when Listbox is rendered dynamicly, the method focus() is not working.
this is my zul:
<textbox id="productionText" width="170px" xmlns:w="http://www.zkoss.org/2005/zk/client">
<attribute w:name="onOK">
<![CDATA[
zk.afterMount(function () {
$('#listOfProduction').first().focus();
});
]]>
</attribute>
</textbox>
<listbox id="listOfProduction" >
</listbox>
this is my Java class
@Listen("onChange=#productionText")
public void setprodactionSearchString(@ContextParam(ContextType.TRIGGER_EVENT) InputEvent even) {
String valueOFSearch = even.getValue();
if (valueOFSearch.length() > 3) {
listProduction = templatesService.getProductionSitesList(valueOFSearch);
for (int i = 0; i < listProduction.size(); i++) {
Listitem listItem = new Listitem();
listItem.setValue(listProduction.get(i)[0]);
listItem.setLabel(listProduction.get(i)[1].toString());
listItem.setParent(listOfProduction);
}
}
}
Thanks a lot
I am more inclined on using the MVVM aproach so here's my working code sample. Type more than four letters on the textbox:
Focus to Listbox's first element
PS: if you take a look at the code, you'll see that I make even a setSelectedIndex. I think is what you want