public
Created

Allows loading of external JavaScript files for use in on{X}

  • Download Gist
loadUnderscore.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
(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'));
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.