Last active
November 5, 2017 00:07
-
-
Save nhunzaker/9676031 to your computer and use it in GitHub Desktop.
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
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 + '>'); | |
} |
I wish gists sent out notifications about comments! I should have updated this, given I was the one that sent out the PR...
Good stuff :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With a04d7da6, you no longer have to override all of
_ensureElement
. Just set a_createElement
that looks like this: