|
| |
User Groups : Forums : SiteExperts :
Dynamic HTML
:  | Namespacing... Hi all,
I have just learnt about "Namespacing" your code to avoid dumping potentially conflicting references into the global space.
Can someone who knows more about this than me tell me if the following code looks OK? ----
[external doc: encaps.js]
if(!TestNameSpace) { var TestNameSpace = {}; } with(TestNameSpace) { method1 = function(arg) { //function body } method2 = function(arg) { //function body } etc. }
---- [in DHTML doc] (**? Hmm, I can't get angle brackets into the message... sorry) Anyway, a call to import the file encaps.js in the document head, then the functions method1(), method2() etc. called directly in the body, just like that (not with TestNameSpace.method1()...
This seems to work, but I'm really not sure if it is achieving the desired code encapsulation.
Thanks for any clarifications!
Started By charriso on Jun 18, 2008 at 3:05:07 AM This message has been edited. |  | | 1 Response(s) | Reply |
| Earlier Replies | Replies 1 to 1 of 1 | Later Replies |  | on (# 1)
| | Earlier Replies | Replies 1 to 1 of 1 | Later Replies |
To respond to a discussion, you must first logon.
If you are not registered, please register yourself to become a member of the SiteExperts.community.
|