Skip to content

Loading…

Avoid throwing when $ is not defined. #1285

Merged
merged 1 commit into from

2 participants

@braddunbar
Collaborator

No description provided.

@jashkenas
Owner

That'll still throw if $ is undeclared. You want window.$ instead, right?

@braddunbar
Collaborator

Yep. Thanks @jashkenas!

@braddunbar
Collaborator

Actually no, $ is a local variable in this case. Possibly undefined, but certainly declared.

@jashkenas jashkenas merged commit 36dfdab into jashkenas:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 5, 2012
  1. @braddunbar
Showing with 2 additions and 2 deletions.
  1. +2 −2 backbone.js
View
4 backbone.js
@@ -1372,8 +1372,8 @@
return Backbone.ajax(_.extend(params, options));
};
- // Set the default ajax method.
- Backbone.ajax = $.ajax;
+ // Set the default ajax method if $ is defined.
+ if ($) Backbone.ajax = $.ajax;
// Wrap an optional error callback with a fallback error event.
Backbone.wrapError = function(onError, originalModel, options) {
Something went wrong with that request. Please try again.