Created
April 6, 2012 23:12
-
-
Save jeffrydegrande/2323857 to your computer and use it in GitHub Desktop.
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
(function() { | |
Thing = {}; | |
Thing.findAll = function(callback) { | |
$.getJSON('/things', function(data) { | |
if (data!=null) { | |
callback(data); | |
} | |
}); | |
} | |
window.Thing = Thing; | |
})(); | |
function doSomethingWithThings(things) { | |
} | |
Thing.findAll(doSomethingWithThings); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I put it in an anonymous function because I have plenty versions of this in which I added functionality afterwards which I did not wanted to be available globally. One version of this for example keeps requests arounds in a hash which I just keep private in that scope without having to come up with safe names to avoid collisions
The var really is missing ... hacked this up in 20 seconds ;)