Skip to content

Instantly share code, notes, and snippets.

@ChrisMissal
Created June 8, 2012 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisMissal/2894063 to your computer and use it in GitHub Desktop.
Save ChrisMissal/2894063 to your computer and use it in GitHub Desktop.
Allows loading of external JavaScript files for use in on{X}
(function() {
device.ajax(
{
url: 'http://underscorejs.org/underscore-min.js',
type: 'GET',
headers: {
'Content-Type': 'text/javascript'
}
},
function onSuccess(body, textStatus, response) {
eval(body);
if (_) console.log('underscore.js loaded successfully');
yourCode(_);
},
function onError(textStatus, response){
console.error('error code: ', response.status);
});
})();
function yourCode(_) {
var stooges = [{name : 'moe', age : 40}, {name : 'larry', age : 50}, {name : 'curly', age : 60}];
console.info(_.pluck(stooges, 'name'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment