Search code examples
javagwtgwtquery

GwtQuery click function not working


I'm trying to figures out why this GwtQuery doesn't work, even how much I click on the label element it doesn't budge:

final Element deleteTD = DOM.createTD();                                            
deleteTD.addClassName("center");
Element span2 = DOM.createSpan();                                   
span2.addClassName("label label-danger");                               
span2.setInnerText("Delete");                               
deleteTD.appendChild(span2);


$(editTD).click(new Function() {                                      
public boolean f(Event e) {                                                   
Window.alert("Edit");                                                     
return false;                                                   
}
});                                         

$(deleteTD).click(new Function() {                                                
public boolean f(Event e) {                                                                                   
return false;                                               
}                                                 
});

row.appendChild(editTD);                                    
row.appendChild(deleteTD);                                  
list.appendChild(row);

Even how much I click, the Window alert doesn't show up, to indicate that the editTD was clicked


Solution

  • I was not able to fix the issue with GwtQuery but with:

                                            DOM.sinkEvents(editTD, com.google.gwt.user.client.Event.ONCLICK);
                                            DOM.setEventListener(editTD, new EventListener(){
                                                @Override
                                                public void onBrowserEvent(
                                                        com.google.gwt.user.client.Event event) {
                                                    if (event.getTypeInt() != com.google.gwt.user.client.Event.ONCLICK) {
                                                        return;
                                                    }
                                                    Window.alert("Edit");
                                                }});