Skip to content

Commit

Permalink
add if statement and add passing test
Browse files Browse the repository at this point in the history
  • Loading branch information
runemadsen authored and tgriesser committed Apr 22, 2013
1 parent c3a1af0 commit 2caf748
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@

// Make the request, allowing the user to override any Ajax options.
var xhr = options.xhr = Backbone.ajax(_.extend(params, options));
model.trigger('request', model, xhr, options);
if(model) model.trigger('request', model, xhr, options);
return xhr;
};

Expand Down
6 changes: 6 additions & 0 deletions test/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,10 @@ $(document).ready(function() {
strictEqual(this.ajaxSettings.beforeSend(xhr), false);
});

test("correctly check for model before triggering request event", 1, function() {
Backbone.emulateHTTP = true;
Backbone.sync('read', false, {url : "/someurl", data : ""})
ok(true, "No errors were thrown");
});

});

0 comments on commit 2caf748

Please sign in to comment.