Skip to content

Instantly share code, notes, and snippets.

@julesbou
Created March 11, 2016 17: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 julesbou/19c5e2ed932febb044cf to your computer and use it in GitHub Desktop.
Save julesbou/19c5e2ed932febb044cf to your computer and use it in GitHub Desktop.
// save a reference to $() method
var view$ = Backbone.View.prototype.$;
// then override it
Backbone.View.prototype.$ = function(selector) {
var element = view$.apply(this, arguments);
if (!element.length === 0) {
console.error("[Backbone.View] Warning: selector '" + selector + "' do not match any element");
}
return element;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment