Fix double loading bug

On an html load, the page was reload by the js "popstate"
This commit is contained in:
chris2tof 2011-12-05 11:22:32 +08:00
parent 77842ab37d
commit 69a8fce64a
1 changed files with 17 additions and 12 deletions

View File

@ -1,26 +1,31 @@
$(function () { $(function () {
$('#panel_sidebar a, #panel_main a.nav').live('click', $('#panel_sidebar a, #panel_main a.nav').live('click',
function () { function () {
$.getScript(this.href); $.getScript(this.href);
history.pushState(null, document.title, this.href); history.pushState(null, document.title, this.href);
return false; history_edited = true;
return false;
} }
); );
$('#panel_main a.reload').live('click', $('#panel_main a.reload').live('click',
function () { function () {
$.getScript(this.href); $.getScript(this.href);
history.replaceState(null, document.title, this.href); history.replaceState(null, document.title, this.href);
return false; history_edited = true;
} return false;
}
); );
$('.form').live('submit', function () { $('.form').live('submit', function () {
$.post(this.action, $(this).serialize(), null, 'script'); $.post(this.action, $(this).serialize(), null, 'script');
return false; history_edited = true;
return false;
}); });
$(window).bind("popstate", function () { $(window).bind("popstate", function () {
$.getScript(location.href); if (history_edited) {
$.getScript(location.href);
}
}); });
}); });