Revision history [back]

click to hide/show revision 1
initial version

answered 2018-01-10 15:38:15 +0800

cor3000 gravatar image cor3000

ZK Team

when dealing with dynamically generated listitems an easy way is to use event forwarding.

<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 = event.getOrigin();
    ListItem listitem = me.getTarget();
}

this will make you live a whole lot easier, since the forward event listeners are added/removed on demand, and all your application has to deal with is a single event listener at the listbox.

Robert

when dealing with dynamically generated listitems an easy way is to use event forwarding.

<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 = event.getOrigin();
    ListItem listitem = me.getTarget();
}

this will make you live life a whole lot easier, since the forward event listeners are added/removed on demand, and all your application has to deal with is a single event listener at the listbox.

Robert

when dealing with dynamically generated listitems an easy way is to use event forwarding.

<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();
}

this will make you life a whole lot easier, since the forward event listeners are added/removed on demand, and all your application has to deal with is a single event listener at the listbox.

Robert

when dealing with dynamically generated listitems an easy way is to use event forwarding.

<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 listitem = me.getTarget();
}

this will make you life a whole lot easier, since the forward event listeners are added/removed on demand, and all your application has to deal with is a single event listener at the listbox.

Robert

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More