-
Bug
-
Resolution: Fixed
-
Minor
-
8.5.0
-
None
-
Security Level: Jimmy
-
None
-
ZK 8.5.2 S1
-
None
Steps to Reproduce
1. run the attached zul
2. click a listitem
Current Result
nothing appears
Expected Result
a notification appears
Debug Information
- if a listitem is statically written in a zul, no issue. If we create a listitem in a template, this issue happens.
- SelectorComposer wires event listeners as expected for comp.addEventListener("onCreate", new AfterCreateWireListener());
- Even with SelectorComposer, we can't listen onClick for dynamically-created listitem e.g. if one listitem is added when clicking a button, ZK doesn't wire it with onClick listener, we need a better way to listen to events for dynamically-created components.
Workaround
- replace macro with <apply>
- use "forward" event
<listbox id="myListbox"> <template name="model"> <listitem forward="onClick=myListbox.onItemClick(${each})"> <listcell/> <listcell/> <listcell/> </listitem> </template> </listbox>
then you can create a listener:
@Listen("onItemClick=#myListbox") public void onItemClick(ForwardEvent event) { //get the data passed into the forward event Object each = event.getData(); //get the original MouseEvent and click target MouseEvent me = (MouseEvent) event.getOrigin(); Listitem listitem = me.getTarget(); }
- relates to
-
ZK-4016 HtmlMacroComponent doesn't listen to onCreate event with @Listen
- Closed