public LIElement appendLI(UListElement ul, String text) { LIElement li = Document.get().createLIElement(); li.setText(text); ul.appendChild(li); return li; }
final UListElement ul = Document.get().createULElement(); final LIElement li1 = appendLI(ul, "my text 1"); final LIElement li2 = appendLI(ul, "my text 2"); HTML myList = HTML.wrap(ul); myList.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Element source = event.getRelativeElement(); if (source != null) { Window.alert(source.getInnerText() + " clicked"); } else { Window.alert("unexpected - event is relative to window"); } } }); Problem solved using plain GWT & you won't create memory leaks. On Wed, Apr 15, 2009 at 9:25 AM, dayre <david.c.a...@gmail.com> wrote: > > HI Vitali, > > Thank you for taking the time to respond. I very much appreciate it. > > The reason i'm not using existing GWT widgets, which my example > doesn't show, is because i'm trying to attach an onclick() event to > ordered list items (<li>text</li>). There doesn't seem to be a > widget which easily allows for this. Someone else in this group had > suggested they do what i was trying to do. I'm trying to port an > existing interface which i did in jquery() to GWT... one of the key > components uses plain list items which i attach listeners to. > > What you explain makes sense and your option #2 for using the jsni > name of the java function seems the easiest. I will also dig into > the JSNI much deeper to fully understand how it works... i was trying > to avoid that ;) > > Again thank you ! > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---