Friday, May 31, 2013

How would like to load the GWT module dyanamically basing on the click of respective link?

I would like to load different gwt modules withIn the main div basing on the click of respective menuItem. I would like to use JQuery. In the below code, I would like to load the fooGwt module if we click on theloadFooModule and similarly, if I click on loadJqueryModule link then JQuery gwt moduleshould be loaded.

Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  <%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>  <%@ taglib prefix="menuItem" uri="menuItem" %>  <html>   <head>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>      <script>    $(document).ready(function() {      $("a").click(function() {            $("#fooModule").empty();            $("#jQueryModule").empty();        $("#main").remove();            alert($(this).text());            if ($(this).text() == "loadJqueryModule") {                    // Jquery gwt module.                $('head').append($("<script id='main' src='/jquery/jquery.nocache.js' />"));             } else {                     // Foo GWt module.                $('head').append($("<script id='main' src='/foo/foo.nocache.js' />"));             }      });    });     </script>   </head>   <body>     <h1>Web Application Starter Project</h1>      <a href="#" id="clickMe">loadFooModule</a>      <a href="#" id="clickMe5">loadJqueryModule</a>      <div id="fooModule">      </div>            <div id="jQueryModule">      </div>         </body>  </html>


O/p: In this it is loading one module which is Foo. The other module was not loading.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment