mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-17 19:21:04 +01:00
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)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user