mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Return jQuery deferred object from LeftAndMain's loadFragment.
This commit is contained in:
parent
b404e55533
commit
137aa53156
@ -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;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user