Loading...

prototype-scriptaculous@googlegroups.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

[Proto-Scripty] Re: accessing objects T.J. Crowder Mon Apr 02 01:00:49 2012

> Here I have to access oneObject.

You can't, it's a local variable within the function you assigned to the 
`createTabs` variable. Unless you export it (make it publicly accessible in 
some way, for instance by assigning it to your `package1` object as a 
property), it's completely private to `createTabs`.

Side note: Your code is falling prey to The Horror of Implicit Globals[1]. 
Strongly recommend properly declaring variables to avoid that.

1: http://blog.niftysnippets.org/2008/03/horror-of-implicit-globals.html

Best,
--
T.J. Crowder
Independent Software Engineer
tj / crowder software / com
www / crowder software / com

On Sunday, 1 April 2012 12:41:16 UTC+1, nav indian wrote:
>
> Hi 
>
> I have two javascript files.
> one.js
> namespace("package1")
> package1.tabs=function(app)
> {
>    this.app = app;
>    this. createTabs();
> } 
>
> createTabs = function(){
>
>   var oneObject = new thirdpartyObject();
>
> }
>
>
> two.js
>
> //Here I have to access oneObject.
>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/XJ20PmyWnIQJ.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.