Skip to content

Instantly share code, notes, and snippets.

@marcmartino
Created September 7, 2012 22:30
Show Gist options
  • Select an option

  • Save marcmartino/3670309 to your computer and use it in GitHub Desktop.

Select an option

Save marcmartino/3670309 to your computer and use it in GitHub Desktop.
inheritence, when i callmyNotes.load, this (inside of load) is the notes object, which is set for EVERY object that inherits from notes
var notes = Object.create(udemObj);
notes.load = function (ajaxPath, callback){
$.ajax({
url: ajaxPath,
type: "GET",
success: ajaxSuccess(loadWrap(this),
function (msg){console.warn(msg);}),
complete: callback
});
};
function loadWrap(_this) {
return function (objList){_this.setData.call(_this, objList);};
}
notes.setData = function (objList){
var noteLiteral, newNote;
for (var m = objList.length - 1; m >= 0; m--) {
newNote = Object.create(note);
newNote = newNote.set(objList[m], newNote);
newNote.arrayNum = this.noteArray.length;
this.noteArray.push(newNote);
}
};
var myNotes = Object.create(notes);
myNotes.load("ajax/getNOtes.php");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment