I have been checking arround some nice effect provided by JQuery scripts, and plugins.
I was thinking of using draggable effect on itmill panels, And if so, is it in all the layouts? havent even tried, so am asking the possibility or if someone has done it. B4 I invest sometime to start the trials.
The trick is to load jquery.js outside the CustomLayout as it does not currently support loading of external js-files. In order to do that I included jquery.js in a manualle edited index.html -file.
In the example, the left and right buttons are implemented on client-side using JQuery for event handling. JQuery animates the div that contains A-button. Both A and B buttons are Toolkit buttons.
so can we now actually put <script type=“text/javascript” src="…/jquery-**.js> in the customerlayout html file or we still need to put it in the index.html. If so, do i need to manually create index.html? because i dont see the file (and i assume it should be an automatically generated html file)
You can override e.g. the method (Abstract)ApplicationServlet.writeAjaxPageHtmlVaadinScripts(), calling the superclass method and then writing out your own script line. This way, it is loaded for every page. The writeAjaxPageHtml* methods of any recent Vaadin version allow customization that makes it unnecessary to use a custom index.html file in 99% of cases.
To use your own application servlet class, you also need to change the reference in your web.xml to point to it.
Hi,
This was exactly the post I was looking for (even though it was written over a year ago ).
With the help of the information in here I managed to get jQuery to work within my Vaadin application.
Thank you guys!
There are however some things I don’t understand.
Question 1:
I looked at the application with the help of firebug and noticed that the scripts that I add in my CustomLayout are prepended with
var document = $doc; var window = $wnd;
Can this be the reason why I can’t get $(document).ready() to work, or is it because what Marc Englund writes in his post above?
In firebug it looks like “document” still is a reference to the DOM document, so I guess this shouldn’t be a problem.
Question 2:
Why do I need to put “window.” before my jQuery statement?
E.g.
window.$("#test").hide(); // works
$("#test").hide(); // doesn't work
Question 3:
I really can’t get jQuery.draggable() to work.
Has anyone tried this?
I’m quite sure you won’t get (document).ready() to work. GWT runs the application javascript inside an IFRAME element, hence the original document object referencing the document of the IFRAME, not the real applicatin DOM. That’s why GWT exposes those $doc and $wnd variables which reference the real DOM. And since that code is run after the initial page load, there probably are several reasons why the listener is never called (i.e. triggered long after the page load, referencing the wrong document element possibly).
Same reason as above: without the window reference, the “anonymous” window reference would point to the IFRAME window object.
What are you trying to drag? Does it work at all, even partially?
I’m having a lot of problems with using jQuery. Alerts are working (at times), but that’s pretty much it.
Debugging is a total PITA, any tips on that? I’m using firefox & firebug & JQuery lint, and my scripts (which mostly consist of alerts at the moment, since nothing else is working) are in a custom html-template. The oddest thing I find is that what works on first page load, won’t work after refresh. I’m having a hard time trying to track what works and what doesn’t as it seems quite random, depending on time of day and position of the stars :cold:
Wanted to add mthat the regular browser tools such as javascript console do not alert that anything is wrong or in error. So the “not working” is exactly that, not working = nothing happening that should be happening.
I am novice in Vaadin and I found myself struggling with similar problem. I want to use this jQuery plugin (http://www.woothemes.com/flexslider/) (too bad there is not similar in Vaadin ). I extended application servlet, override writeAjaxPageHtmlHeader method and add jQuery and flexslider js file, but I can’t execute code which allow me to create this content slider. I found your respone and this is what I need, unfortunately I can’t make it work Could you help me guys?
How did you manage to execute this javascript code which is at the end of the body tag (How did you put it there)?