Skip to content

Instantly share code, notes, and snippets.

@stringparser
Forked from nhunzaker/isomorphicish.js
Last active August 29, 2015 14:26
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 stringparser/bf464b0043b2c5823196 to your computer and use it in GitHub Desktop.
Save stringparser/bf464b0043b2c5823196 to your computer and use it in GitHub Desktop.
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