Return jQuery deferred object from LeftAndMain's loadFragment.

This commit is contained in:
Mateusz Uzdowski 2013-08-23 09:39:38 +12:00
parent b404e55533
commit 137aa53156
2 changed files with 12 additions and 1 deletions

View File

@ -542,6 +542,8 @@ jQuery.noConflict();
// Store the fragment request so we can abort later, should we get a duplicate request.
fragmentXHR[pjaxFragments] = xhr;
return xhr;
},
/**

View File

@ -319,7 +319,7 @@ Upon the receipt of the response, the fragment will be injected into DOM where a
has been found on an element (this element will get completely replaced). Afterwards a `afterloadfragment` event
will be triggered. In case of a request error a `loadfragmenterror` will be raised and DOM will not be touched.
You can hook up a response handler that obtains all the details of the XHR request like this:
You can hook up a response handler that obtains all the details of the XHR request via Entwine handler:
'from .cms-container': {
onafterloadfragment: function(e, data) {
@ -328,6 +328,15 @@ You can hook up a response handler that obtains all the details of the XHR reque
}
}
Alternatively you can use the jQuery deferred API:
$('.cms-container')
.loadFragment('admin/foobar/', 'Fragment1')
.success(function(data, status, xhr) {
// Say 'success'!
alert(status);
});
## Ajax Redirects
Sometimes, a server response represents a new URL state, e.g. when submitting an "add record" form,