- bug fix: in-browser source include loading - 11d4a00
All dependencies are peer dependencies now and you no longer provide Backbone and underscore when initializing backbone-xhr-events.
The initialization is now just
require('backbone-xhr-events');
- rename "whenFetched" to "ensureFetched" - f88cabf
- don't eager set options.url (it can be accessed with "before-send" event) - d3de6a8
Compatibility notes:
This should really be a minor release but I'm not doing one since I just pushed a minor release this morning. I am no longer forcing options.url to have a value and letting Backbone.sync work naturally. The only real difference to you is that options.url
is only accessable if you provided url
as an option when making the xhr call (like model.fetch({url: '...'})
.
If you want to get the actual URL, you will need to access the ajax settings (what Backbone.sync provides to $.ajax) which you get as a parameter with the before-send
event. So, to get the URL it would look like this:
model.on('xhr', function(requestContext) {
requestContext.on('before-send', function(xhr, settings) {
console.log('the URL is ' + settings.url);
});
});
- bug fix: ensure RequestContext is the first param for xhr & xhr:{method} events - c7499ee
Pretty major changes in this release
- The RequestContext object is now the last parameter on all of the lifecycle methods (where it was the first)
- preventDefault functionality has been completely overhauled and is very different - see docs for more details but preventDefault is now a method to be called. The response from this method has 3 methods (success/error/complete) and one of these methods must be called to complete the response.
The docs have changed quite a bit for this release so check them out for the updated API and some additional usage examples
- make preventDefault a function rather than a boolean value to be set on the context
- add a "finish" function attribute on context which must be called if preventDefault is called in "after-send"
context.on('after-send', function(data, status, xhr, responseType) {
context.preventDefault();
context.finish({
// indicate that the xhr callbacks will be handled manually
preventCallbacks: true,
// indicate that the lifecycle events will be handled manually
preventEvents: true
});
});
See API docs for added examples which demonstrate how this can be used
- code cleanup - 636e162
no functional code changes. There is just an additional comment that is used to create react-backbone/with-deps.js
- API change forwardXhrEvents -> forwardXHREvents and stopXhrForwarding -> stopXHRForwarding - 9d0d67b
- fetch bug fix - eb10cd0
- allow fetch state flags to be reset if the collection has been reset or the model has been cleared - e4db226
- for AMD, you must execute the function with params (see README AMD install instructions) - da7c5d9
require(
['backbone', 'underscore', 'backbone-xhr-events'], function(Backbone, _, backboneXhrEvents) {
backboneXhrEvents(Backbone, _);
});
The underscore impl must be provided to the CommonJS function (see README CommonJS install instructions)
require('backbone-xhr-events')(require('backbone'), require('underscore'));
- update README - d0a7dea
- bug fix: ensure that the xhr activity state is correct even if a success/error callback pukes - e8c1d97
- add responseType to 'after-send' event - f60acdf
Compatibility notes: This should really be a minor release but I just performed a minor release and I don't believe anyone will be using this event yet
- add abort context method - bcd77bd
- add "abort" context method - 0d95e6a
- change "data" event to "after-send" and "request" context attribute to "data" - 5cb80b5
- remove model from context lifecycle event params - 782050c
- add "before-send" context event - f446504
- change context.stop to context.preventDefault - 937bb2a
- change context.intercept to context.preventDefault - 81c18ea
Compatibility notes: if you are using context.stop or context.intercept, use context.preventDefault instead.
context.intercept = function(options) {
options.success(...);
}
to
context.preventDefault = true;
context.options.success(...);
- add whenFetched method - 7c4d1ba
- rename to backbone-xhr-events - 5b7d4be
Large rewrite with additional features / existing features are not backwards compatible *note: this is the last release of backbone-async-event. The project will be renamed to backbone-xhr-events
- allow event names and referenced attributes to be overridden
- use "xhr" instead of "async" for event names
- change signature of all event parameters
- provide event forwarding capabilities
- additional 'data' context event
Your best bet is to look at the updated README file to see the new features
- update README for hasBeenFetched/hadFetchError - f97acfd
- add Model/Collection.hasFetchError - d31b0af
- change Model/Collection.hasBeenFetched() to Model/Collection.hasBeenFetched (boolean rather than function) - d3f4ad6
- make sure options.url exists before firing events - d0235a1
- add "hasBeenFetched" to Backbone.Model and Backbone.Collection - da4ce8e
- add "isLoading" API docs to README - c2702a3
- add Backbone.async which can be used to track any async events - 2b03cad
- added "options.intercept" ability to forcefully override an ajax response - 73a858e
- fix author email address - 8e9201a
- remove backbone as a dependency - 1ad0255
- require Backbone to be passed as param for commonJS init - a63f4c9
- add global event handler support