javascript - How to use this for the main object on Object Literal Notation -


i'm learning object literal notation, i'm trying to, or think i'm doing bit complex. example

what i'm trying accomplish

  • initializa object
  • store jquery object
  • request json
  • build html json , use promise

(disclaimer, i'll hope can excuse english , lack of vision point out issue)

var objeto = objeto || (objeto = {     jsonurl:"/something",     container:{},     triggercontainer:{},      property1:{},     init:function(var0,var1){         this.container = $(var0);         this.triggercontainer = $(var1);         // ignoring details proceed set event         this.loader()     },     loader:function(){         // here scope objeto, far         // have create self because scope change, right?         self = this;         this.triggercontainer.on("click",function(){             // now, i'm going request json making promise             promiseme = jquery.getjson(self.jsonurl);             promiseme.done(self.build);             // now, did in way beacuse think looks bit cleaner             // of course problem come next         });     },     build: function(data) {         /*           here is, scoped promise, , want use data            build html, want append objeto.container, , don't            know how access, , did know how pass refence .done()          */     }  }); 

i'm pretty sure, messing structure. maybe i'm not using right. if so, please explain me i'm doing wrong

thank in advance.


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -