GWT:我使用jQuery的jScrollPane,它是否搞乱了我的ClickHandlers? [英] GWT: I am using jScrollPane with jquery, is it messing with my ClickHandlers?

查看:137
本文介绍了GWT:我使用jQuery的jScrollPane,它是否搞乱了我的ClickHandlers?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b

  function scrollPane(){
$( .gwt内容)JScrollPane中();
}

自定义Widget会被添加:

$(。jspPane)。append($(new Content());

作品



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





  html.addClickHandler(new ClickHandler(){

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

html是一个带有一些Text和另一个HTML小部件的HTML Widget。



真正的问题是:I我想知道是否可以实现一个CellTable并使用GWTQuery来添加一个ClickListener。

如果你需要更多的信息或来源告诉我。



谢谢

解决方案

为了让JScrollPane可以包含一个小部件,您必须将它提升到一个gwt面板,因为它已经由jquery创建。



Gwt是严格的,因为您必须拥有一致的窗口小部件层次结构。



Gquery操纵dom,并将与它一起添加的小部件的元素视为元素,并且不会插入到小部件树中,除非您使用gwtquery中的特定方法来执行此操作。



您可以使用以下任一方式解决问题:



Gquery :这仅适用于上次快照

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

Gwt :这里你必须为你的jsPane设置一个id p>

  Widget myContent = new Content(); 
面板jsPane = RootPanel.get(jsPaneId);
jsPane.add(myContent);


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

解决方案

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);

这篇关于GWT:我使用jQuery的jScrollPane,它是否搞乱了我的ClickHandlers?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆