On 13/01/2012, at 7:24 AM, Farrukh Najmi wrote: > 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($) { Remove the $. You don't have any dependencies. > > 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]); > } > } > }); You need to return removeBlankFields, otherwise the module that depends on this has no reference to it. > > 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) { removeBlankFields won't be available because you did not return it. > > 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 May be you don't have any dependency injection requirement. > }; > > // 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. I think that you might also benefit from posting to the require.js mailing list which is where AMD is discussed.
Kind regards, Christopher