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',
function () {
$.getScript(this.href);
history.pushState(null, document.title, this.href);
return false;
history.pushState(null, document.title, this.href);
history_edited = true;
return false;
}
);
$('#panel_main a.reload').live('click',
function () {
$('#panel_main a.reload').live('click',
function () {
$.getScript(this.href);
history.replaceState(null, document.title, this.href);
return false;
}
history.replaceState(null, document.title, this.href);
history_edited = true;
return false;
}
);
$('.form').live('submit', function () {
$.post(this.action, $(this).serialize(), null, 'script');
return false;
$.post(this.action, $(this).serialize(), null, 'script');
history_edited = true;
return false;
});
$(window).bind("popstate", function () {
$.getScript(location.href);
$(window).bind("popstate", function () {
if (history_edited) {
$.getScript(location.href);
}
});
});