开发者

why this event (onclick) do not fire?

开发者 https://www.devze.com 2023-02-20 01:00 出处:网络
UI: <div class=\"scroll\" ui:field=\"mainContainer\"> <ul ui:field=\"liContainer\"> </ul>

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

精彩评论

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