Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var _ = require('underscore');
var Backbone = require('backbone');
var cheerio = require('cheerio');
var request = require('request');
Backbone.ajax = function(options) {
options.json = true;
return request(options, function(error, result) {
if (error) {
if (_.has(options, 'failure')) options.failure(error);
} else {
(if (_.has(options, 'success')) options.success(result.body);
}
});
};
Backbone.View.prototype.setElement = function($cheerio) {
this.$el = $cheerio("*");
return this;
},
Backbone.View.prototype._createElement = function(tagName) {
return cheerio.load('<' + tagName + '>');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment