Skip to content

Instantly share code, notes, and snippets.

@jackwanders
Last active December 31, 2015 15:48
Show Gist options
  • Save jackwanders/8008941 to your computer and use it in GitHub Desktop.
Save jackwanders/8008941 to your computer and use it in GitHub Desktop.
A simple require plugin to allow us to require a pre-fetched instance of a backbone model or collection
define({
load: function(name, req, onLoad, config) {
'use strict';
if(config.isBuild) { onLoad(null); } // prevent errors w/ synchronous optimizer
else {
req([name], function(BackboneClass) {
var obj = new BackboneClass();
obj.fetch({
success: function(instance) {
onLoad(instance);
}
});
});
}
}
});
@aducore
Copy link

aducore commented Dec 17, 2013

nice

@nmielnik
Copy link

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment