This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes GWT and the fly likes Inject javascript in the UiBinder file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "Inject javascript in the UiBinder file" Watch "Inject javascript in the UiBinder file" New topic
Author

Inject javascript in the UiBinder file

Vikram Kohli
Ranch Hand

Joined: Nov 27, 2005
Posts: 174
Hi All,


I need to include a java script in my UiBinder composite view.I am preety new to GWT world. So following is what I have done so far to achieve this:-


1) Have put up an entry in my gwt module xml file


2) Following is my Composite Code


3) Following code is there in my UiBinder corresponding java file



4) And finally code in my javascript file


My Problem is still I ma getting the following error while running my GWT app. Please help to solve the issue
Caused by: com.google.gwt.core.client.JavaScriptException: (ReferenceError): '$' is undefined
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:237)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:289)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
at com.praclabs.client.view.HomeView.bind(HomeView.java)
at com.praclabs.client.view.HomeView.onAttach(HomeView.java:16)
at com.google.gwt.user.client.ui.Widget.setParent(Widget.java:470)
at com.google.gwt.user.client.ui.Panel.adopt(Panel.java:127)
at com.google.gwt.user.client.ui.LayoutPanel.insert(LayoutPanel.java:195)
at com.google.gwt.user.client.ui.LayoutPanel.add(LayoutPanel.java:134)
at com.praclabs.client.AppController.onValueChange(AppCon

Regards,
Vikram


Vikram PracLabs
Benjamin Possolo
Greenhorn

Joined: Dec 27, 2011
Posts: 1
the jquery object ($) is bound to the window object.

within JSNI methods, you access the window object via $wnd.

therefore to access the jquery object within a JSNI method you need to do:

$wnd.$('#someSelector')

or for clarity, access the jquery object by its long name:
$wnd.jQuery('#someSelector')
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10172
    
    8

Welcome to the Ranch Benjamin!


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
wood burning stoves
 
subject: Inject javascript in the UiBinder file
 
Similar Threads
external CSS in UiBinder
Using Background Images in CSS with sprite
GWT ToggleButton with UiBinder template does not work
Problems with click/touch events in GWT mobile using UiBinder
how to add uibinder widget to gxt dialog? Layouts not working and contents disappear on resize