-
-
Save nnance/4d4b162d02c4923d5b5b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 + '>'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment