javascript - Why can't I reference an object literal from inside an object literal? -


Not sure if this is possible or if I am doing it wrong I am trying to keep an actual reference to an object I am the one who is one of my properties, which is another object literally, I am getting an error stating that it is undefined:

  var MyObject = {init: function () {this.elements.buttons.click (function () {alert ('hit');}); }, Element: {button: $ ('button')}}   

What am I doing?

UPDATE: Main.JS demand which may possibly cancel the scope -

  Function Execution Performance Name (functionName, context / *, args * /) {var args = [] .slice.call (arguments) .splice (2); var namespace = functionName.split ("."); Var func = namespaces.pop (); For (var i = 0; i    

If you do that work directly MyObject , this will be undefined. This with MyObject and it should work.

It will not work as will be defined DOE :

  var MyObject = {// init: ...} var init = MyObject.init; in this ();   

See Entering 3 Function Code :

If you want to continue using this , you can use or like it:

  var MyObject = {// init: ...} var init = MyObject.init; init.call (MyObject);    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -