mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 22:45:46 +01:00
prevent same state from loading again
This commit is contained in:
@@ -3,10 +3,13 @@
|
|||||||
var rootUrl = document.location.protocol + '//' + (document.location.hostname || document.location.host) + (document.location.port ? ':'+document.location.port : ''),
|
var rootUrl = document.location.protocol + '//' + (document.location.hostname || document.location.host) + (document.location.port ? ':'+document.location.port : ''),
|
||||||
content = null;
|
content = null;
|
||||||
|
|
||||||
|
var current_state = '';
|
||||||
|
|
||||||
|
|
||||||
$('document').ready(function() {
|
$('document').ready(function() {
|
||||||
if (!window.history || !window.history.pushState) return; // no ajaxification for old browsers
|
if (!window.history || !window.history.pushState) return; // no ajaxification for old browsers
|
||||||
|
|
||||||
|
|
||||||
content = content || document.getElementById('content');
|
content = content || document.getElementById('content');
|
||||||
|
|
||||||
$('a').unbind('click').bind('click', function(ev) {
|
$('a').unbind('click').bind('click', function(ev) {
|
||||||
@@ -14,13 +17,21 @@
|
|||||||
var tpl_url = (url === '') ? 'home' : url;
|
var tpl_url = (url === '') ? 'home' : url;
|
||||||
|
|
||||||
if (templates[tpl_url]) {
|
if (templates[tpl_url]) {
|
||||||
|
if (current_state != url) {
|
||||||
|
current_state = url;
|
||||||
|
|
||||||
window.history.pushState({}, url, "/" + url);
|
window.history.pushState({}, url, "/" + url);
|
||||||
content.innerHTML = templates[tpl_url];
|
content.innerHTML = templates[tpl_url];
|
||||||
exec_body_scripts(content);
|
exec_body_scripts(content);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user