Update ajaxify logic w/ returnPath support

If returnPath is defined, and url is null, then ajaxify will
execute a replaceState instead of an ajaxification.

Used in cases where a separate route is pushed but you'll want to
return to the page you were on previously. (see: #4371)
v1.18.x
Julian Lam 9 years ago
parent c8b179e492
commit 54e36f7c54

@ -22,10 +22,16 @@ $(document).ready(function() {
$(window).on('popstate', function (ev) {
ev = ev.originalEvent;
if (ev !== null && ev.state && ev.state.url !== undefined) {
ajaxify.go(ev.state.url, function() {
$(window).trigger('action:popstate', {url: ev.state.url});
}, true);
if (ev !== null && ev.state) {
if (ev.state.url === null && ev.state.returnPath !== undefined) {
window.history.replaceState({
url: ev.state.returnPath
}, ev.state.returnPath, config.relative_path + '/' + ev.state.returnPath);
} else if (ev.state.url !== undefined) {
ajaxify.go(ev.state.url, function() {
$(window).trigger('action:popstate', {url: ev.state.url});
}, true);
}
}
});

Loading…
Cancel
Save