aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes modularization in java script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "modularization in java script" Watch "modularization in java script" New topic
Author

modularization in java script

Trilochan Bharadwaj
Ranch Hand

Joined: Feb 02, 2009
Posts: 100
Hi,

I have something like this in jsDir/nms.js:

And then i have a jsDir/nms/aop/nms-aop.js with:



How do i use nms-aop.js's NMS.AOP module inside of NMS in nms.js ...? Any thoughts, inputs?

Trilochan


Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

You don't. That style of script is specifically geared towards making things self-contained and unshareable. You'll need to do something to make the functions you want to use externally visible, or change the way that they're declared in the first place.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Trilochan Bharadwaj
Ranch Hand

Joined: Feb 02, 2009
Posts: 100
Thanks for your reply.I don't have the svn snapshot for Dojo, but I basically wanted to do something like: dojo.require( "dijit.widget.*"); within NMS namespace; and then allow it to be used throughout my different JS modules ... like NMS.require( " " );, my question is more geared towards providing me with conceptual understanding or snippet of how that can be done ...

Any pointers?
Trilochan Bharadwaj
Ranch Hand

Joined: Feb 02, 2009
Posts: 100
OK, Just for follow up, I got around the problem by doing something like:



I know there is a better way of doing it (I am thinking that we provide a file path name in a.b.c form and then traverse through folders to get the URI and then do an eval on the js file to get hold of object hierarchy ... I'll give that a try too, but I thought this was easy enough to do.

Trilochan.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: modularization in java script