Created
September 7, 2012 22:30
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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