I've cut and pasted most of Matthew's instructions below and highlighted in red what I did to allow gwt-Labels to be draggable. I'm hoping I can apply the same logic to other javascript libraries and gwt widgets.
1. Reference the jQuery and jQueryUI libraries in your web page
2. Reference the GWT application in your web page
3. Create a JSNI method to call jQuery
// Using Selector4. Call the method from within GWT
public static native void draggable(String selector) /*-{
$wnd.jQuery(selector).draggable();
}-*/;
// Using Selector
RootPanel.get(sectionTagID).add(new Label("draggable label");
draggable(".gwt-Label");
One thing to note is that "sectionTagID" must be the id of a <section> tag and not a <div> tag.
e.g.
<section id="id_of_section_tag"></section> will work,
I tried using an id of a div tag, but the RootPanel.element.add() function didn't even work. i.e. no GWT labels were added to my webpage. (Perhaps you can suggest a reason).
I will try and write a step-by-step when I get some more time and have played more with other javascript libraries and GWT widgets, but hopefully there's enough here to inspire you to try it out in the meantime.
No comments:
Post a Comment