Steps to Reproduce
<listbox id="lb" mold="select" multiple="true" height="200px">
<listgroup label="group 1"/>
<listitem id="li1" label="Item 1"/>
<listitem id="li2" label="Item 2"/>
<listgroup label="group2"/>
<listitem id="li3" label="Item 3"/>
</listbox>
<button onClick="li3.setSelected(true);" label="select item 3"/>
click the button
Current Result
zul.sel.wpd:3684 Uncaught (in promise) TypeError: option.isSelected is not a function
at init._changeSelect (zul.sel.wpd:3684)
at init.setChgSel (zul.sel.wpd:3677)
at Function._set2 (zk.wpd:12126)
at init.setter.func (zk.wpd:21749)
at init.zk.Widget.zk.$extends.set (zk.wpd:21777)
at setAttr (zk.wpd:30325)
at Object.setAttrs (zk.wpd:30342)
at doProcess (zk.wpd:28737)
at doCmdsNow (zk.wpd:28837)
at Object._doCmds (zk.wpd:29201)
Expected Result
"Item 3" is selected
Debug Information
there are listgroups (zul.sel.Optgroup) in the listbox which don't have an isSelected method
Workaround
override the _changeSelect method to only handle zul.sel.Option widgets
zk.afterLoad('zul.sel', function() { var xSelect = {}; zk.override(zul.sel.Select.prototype, xSelect, { _changeSelect : function(option, toSel) { if(option.$instanceof(zul.sel.Option)) { return xSelect._changeSelect.apply(this, arguments); } return false; } });//zk.override });//zk.afterLoad
- relates to
-
ZK-4987 Listbox using form object as model doesn't resolve selectedItems
-
- Open
-