0

I am updating a vaadin project from vaadin 6 version to vaadin 7. It contains some native Javascript methods which work well in the old version. However some of them throw an exception when they should be called. I am not acquainted enough to Javascript programming and therefore I am not able to identify the source of the error. In particular the method is:

 protected static native void addSthToImg()
    /*-{
        $wnd.$(document).ready(function() {
            var = $wnd.$;
            var('.settingswrapper > img').addClass("imgStartup");
            if (var('.settingswrapper > img').hasClass("imgStartup")) {
                console.log("imgStartup exist");
                var('.settingswrapper > img')
      .animate(null, 300, function() {
                    var('.settingswrapper > img').removeClass("imgStartup");
                    var('.settingswrapper > img').addClass("imagePopIn");

                });
            }
        });
    }-*/;

On the Console in Chrome I see the error stack trace:

Caused by: com.google.gwt.core.client.JavaScriptException: (TypeError) : Object [object global] has no method '$'

What could be a possible cause of the error and why is it working in the old version? Is a jar/library missing?

arjacsoh
  • 8,932
  • 28
  • 106
  • 166

1 Answers1

0

Seems like jQuery alias $ is not defined in the global scope (denoted by $wnd). Are you sure your page includes jQuery?

You should have something like <script src="/js/jquery.js" type="text/javascript"></script> (but pointing to the actual location of jquery.js in your project) in your HTML source. I don't know if Vaadin manages JavaScript libraries automatically, since I'm not familiar with the framework.

siledh
  • 3,268
  • 2
  • 16
  • 29