Problem: loading external javascript classes

6 views
Skip to first unread message

de...@chuwori.co.uk

unread,
Jun 23, 2011, 4:03:42 PM6/23/11
to opensoci...@googlegroups.com
Could somebody please tell me why example 1 works and example 2 doesn't.
Correct code would be appreciated.
Thanks in advance.

I've included the contents of 2 external javascript files.
Example 1 is called from my gadget with:
emouseatlas.emap.stg_run("my url");
This works OK.

Example 2 is called from another gadget with:
emouseatlas.emap.RunMe.stg_run("my url");
This does NOT work. I get the error: emouseatlas.emap.RunMe is undefined
=========================================================
Example 1:
if(!emouseatlas) {
   var emouseatlas = {};
}
if(!emouseatlas.emap) {
   emouseatlas.emap = {};
}
emouseatlas.emap.stg_run =  function(url) {
    var _debug=true;
     //output to firebug 
        if(_debug) {
                 console.log("inner scope stg_run %s",url);
        }
   
    };//end stg_run

================================
Example 2
if(!emouseatlas) {
   var emouseatlas = {};
}
if(!emouseatlas.emap) {
   emouseatlas.emap = {};
}
emouseatlas.emap.RunMe = function() {
    var _debug=true;
    stg_run =  function(url) {
   
         //output to firebug 
        if(_debug) {
                 console.log("inner scope stg_run %s",url);
        }   
    };//end stg_run
}();//end RunMe

===========================================

Robson Dantas

unread,
Jul 8, 2011, 8:16:33 AM7/8/11
to opensoci...@googlegroups.com
On example 2, use var stg_run = function(url) . "var"  is missing.

Inner scope has this weird stuff. You can also open chrome console and check the object. You will note that this  variable didn't bind any object.

--
Robson Dantas
@robsondantas

Sent from my mobile device
--
You received this message because you are subscribed to the Google Groups "orkut Developer Forum" group.
To view this discussion on the web visit https://groups.google.com/d/msg/opensocial-orkut/-/hq3EtahoacQJ.
To post to this group, send email to opensoci...@googlegroups.com.
To unsubscribe from this group, send email to opensocial-ork...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/opensocial-orkut?hl=en.
Reply all
Reply to author
Forward
0 new messages