开发者

why this event (onclick) do not fire?

UI:

  <div class="scroll" ui:field="mainContainer">
                <ul ui:field="liContainer">
                </ul>
    </div>

code :

LIElement li = Document.get().createLIElement();
AnchorElement a = Document.get().createAnchorElement();
a.setAttribute("href", "#");
li.appendChild(a);
Image img = new Image(fsd.getImgUrl());
img.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
        Window.alert("Hello, again");
    }
});
SpanElement span = Document.get().createSpanElement开发者_运维技巧();
span.setInnerText(fsd.getName());
a.appendChild(img.getElement());
a.appendChild(span);
liContainer.appendChild(li);

Note:

@UiField
UListElement liContainer;


The Image must be added to a parent Widget. By attaching the image's element directly to the DOM, you wind up bypassing GWT`s event dispatch system.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜