Skip to content

Instantly share code, notes, and snippets.

@Jiert
Created August 20, 2015 21:30
Show Gist options
  • Save Jiert/5525863a6d729d6376b2 to your computer and use it in GitHub Desktop.
Save Jiert/5525863a6d729d6376b2 to your computer and use it in GitHub Desktop.
Image Loading with Underscore
initialize: function(){
_.bindAll(this, 'render', 'onImgLoad');
this.mainImg = new Image();
this.mainImg.src = this.model.get('img');
this.userImg = new Image();
this.userImg.src = this.model.get('admin').img;
this.mainImg.onload = this.onImgLoad;
this.userImg.onload = this.onImgLoad;
},
onImgLoad: _.after(2, function(){
this.render();
}),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment