I'm trying to integrate Opentip into a GWT project. Since some of my widgets are loaded from Java instead of the HTML, it seems like I'll have to use JSNI to get those tooltips bound properly. Here's what I've done so far:
- Put the relevant JS/CSS declarations before GWT's
nocache.js
in my HTML file. (I also tried duplicating the JS loading by usingScriptInjector
, but that didn't do any good, so I ripped it out as redundant. Written a JSNI method to instantiate the tooltips:
private native void initControlTooltips() /*-{ var headerText = "Tooltip text"; new $wnd.Opentip($("#tooltipTrigger"), headerText); // more tooltips... }-*/
I've tried different variants of the above method, but I've read that this is the way it's supposed to work (Slide 20 here, though I can't link directly to the slide). So far I've had no luck, and this most recent attempt, which seems the most correct to me, has actually stopped the rest of my GWT module from loading (after the tooltip instantiation call), as if I have a syntax error somewhere, though the console isn't reporting anything. Any ideas as to what I'm doing wrong? I'm relatively new to both GWT and JS, so I'm hoping this is just a stupid beginner's mistake.
The one thing I haven't tried yet is coding up an Overlay object, partially because I can't see from the docs how to properly wrap a JS constructor. If that's the solution here, some pointers on how to do that would be welcome. As a reference, the constructor I'd be using (from the Opentip documentation) is:
new Opentip("#my-trigger-element", "Optional content", "Optional title", { ...options... });
Thanks for any help; this doesn't seem like it should be that tough of a problem, but so far my inexperience has foiled my efforts.
Update
After several hours of cursing and parameter fiddling, I've resolved this, so don't waste any time trying to help me debug. I'll write up an answer a little later today when I get a bit of free time.