-
FEATURED COMPONENTS
First time here? Check out the FAQ!
1 | initial version | |
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
2 | No.2 Revision |
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
3 | No.3 Revision |
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
4 | No.4 Revision |
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