-
Bug
-
Resolution: Fixed
-
Normal
-
8.6.3
-
Security Level: Jimmy
-
ZK 9.0.1 S1
Steps to Reproduce
<zk> <zscript> ListModelList model = new ListModelList(); </zscript> <chosenbox width="300px" creatable="true" model="${model}" onSearch='model.add(event.value); model.addToSelection(event.value);' /> </zk>
1) create a new item 'AAA'
2) remove the item 'AAA'
3a) add the item 'AAA' again
3b) create the item 'AAA' again
Current Result
1) item added OK
2) item removed OK
3a) the item doesn't appear in the choices
3b) after re-creating 'AAA' it appears twice
Expected Result
3a) item should be available in the model (unless removed from java code)
3b) re-creating the same item should not be necessary/possible
Debug Information
trying to remove unselected items from the model leads to a JS error
add 'AAA'
then 'BBB'
then remove 'BBB'
<zk> <zscript> ListModelList model = new ListModelList(); </zscript> <chosenbox width="300px" creatable="true" model="${model}" onSearch='model.add(event.value); model.addToSelection(event.value);' onSelect='model.removeAll(event.unselectedObjects);' /> </zk>
-->
zk.wpd:27427 Uncaught TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'. at init._updateListContent (zkmax.inp.wpd:9) at Object.invoke (zk.wpd:28677) at doProcess (zk.wpd:26925) at doCmdsNow (zk.wpd:27025) at Object._doCmds (zk.wpd:27392) at Object.afterResponse (zk.wpd:27898) at XMLHttpRequest._onResponseReady (zk.wpd:27753)
Adding an initial item avoids the problems from above.
However the initial item can not be removed successfully, it always reappears in the available choices.
<zk> <zscript> ListModelList model = new ListModelList(); model.add("INITIAL DUMMY"); </zscript> <chosenbox width="300px" creatable="true" model="${model}" onSearch='model.add(event.value); model.addToSelection(event.value);' onSelect='model.removeAll(event.unselectedObjects);' /> </zk>
Workaround
use an empty dummy item, even 'null' works, and filter it out later, or make sure there's at least 1 initially available option