GWT: I am using jScrollPane with jquery, is it messing with my ClickHandlers?

时光怂恿深爱的人放手 提交于 2019-12-13 02:40:34

问题


I implemented the JScrollPane for a cleaner look inside my Page.

function scrollPane() {
$(".gwt-content").jScrollPane();
}

A custom Widget gets added:

$(".jspPane").append($(new Content());

works

$(html).click(new Function() {
public boolean f(Event e) {
System.out.println("yo");
return true;
}
});

doesn't

html.addClickHandler(new ClickHandler() {

@Override
public void onClick(ClickEvent event) {
System.out.println("yo1");
}
});

html is a HTML Widget with some Text and another HTML widget in it.

The real problem is: I want to add a CellTable into the jspPane, but the listener in the ClickableTextCell is removed. I don't know if I can implement a CellTable and use GWTQuery to add a ClickListener.

Well, any help is appreciated, if you need more infos or source tell me.

Thanks


回答1:


In order that the JScrollPane could contain a widget, you have to promote it to a gwt panel since it has been created by jquery.

Gwt is strict in the sense that you must have a consistent widget hierarchy.

Gquery manipulates the dom, and elements of widgets added with it are treated as elements and are not inserted in the widgets tree unless you use specific methods present in gwtquery to do that.

You can solve your problem using either way:

Gquery: this only works with last snapshot

Widget myContent = new Content();
Panel jsPane = $(".jspPane").as(Widgets.Widgets).panel().widget();
jsPane.add(myContent);

Gwt: here you have to set an id to your jsPane

Widget myContent = new Content();
Panel jsPane = RootPanel.get("jsPaneId");
jsPane.add(myContent);


来源:https://stackoverflow.com/questions/12935354/gwt-i-am-using-jscrollpane-with-jquery-is-it-messing-with-my-clickhandlers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!