Last active
December 31, 2015 15:48
-
-
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
This file contains 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
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); | |
} | |
}); | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice