(Resending to show Utility module as it is in 1.js)

Hi Christopher,

After spending considerable time I am still stuck in getting my JS project to work inside my war project.

   * My js project successfully produces artifacts:
     myproject-4.9-SNAPSHOT.js, myproject-4.9-SNAPSHOT-min.js

   * I successfully install these artifacts in the correct places in a
     separate war project. Here is what a my simple Utility module
     looks like

     /*global define */

     define( "org/xyz/Utility", [ ], function($) {

          function removeBlankFields(form) {
              var inputs, removeList, i, x;
              inputs = form.getElementsByTagName("input");
              removeList = [];
              for (i=0; i<inputs.length; i++) {
                  if (inputs[i].value === "") {
                      removeList.push(inputs[i]);
                  }
              }
              for (x in removeList) {
                  removeList[x].parentNode.removeChild(removeList[x]);
              }
          }
     });

   * I am unsure what I have to do in the IndexContext.js file. For now
     here is what I do

     define([ "jquery", "org/xyz/Utility" ],
              function($, *removeBlankFields*) {

          function IndexContext(){}

          /**
           * Initialize this context.
           *
           * Instantiates HelloWorld components, injects dependencies,
     and starts
           * the HelloWorldController.
           */
          IndexContext.prototype.initialize = function() {
     *        //Not sure what I am supposed to do here for injecting
     dependencies*
          };

          // Return the function
          return IndexContext;

     });


   * I try using the *removeBlankFields* function as onsubmit function
     for the form. See simplified example below...:

     <html><head>
     <title>Query: Basic Query</title>
     <script src="../../doc/js/almond-0.0.2-SNAPSHOT.js"
     type="text/javascript"></script>
     <script src="../../doc/js/jquery-amd-1.7.1-SNAPSHOT.js"
     type="text/javascript"></script>
     <script src="../../doc/js/jquery-ui-amd-1.8.16-SNAPSHOT.js"
     type="text/javascript"></script>
     <script src="../../doc/js/omar-server-web-js-4.9-SNAPSHOT.js"
     type="text/javascript"></script>
     </head>
     <body>
     <h1>Query: Basic Query</h1>
     <br>
     </p><form onsubmit="*removeBlankFields(this)*;" method="get"
     action="../search" name="Query: Basic Query-form">
     <input type="checkbox" value="false"
     name="matchOnAnyParameter">Match on ANY Parameter<br>
                      Name: <input type="text" name="name"><br>
                      Description: <input type="text"
     name="description"><br>
     <p></p>

     </body></html>

The problem is that the function removeBlankFields never gets called and Firebug never logs any error either. My guess is that there may be one or both of teh following issues:

   * I am not implementing the IndexContext.prototype.initialize correctly
   * I need to somehow use a module qualified name for the
     *removeBlankFields* function


Can you please guide me over the hump on this. It would great if I can get this minor glitch resolved rather than give up and do things the old fashioned way.
Thanks for your help.

--
Regards,
Farrukh Najmi

Web:http://www.wellfleetsoftware.com

Reply via email to