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

@ -3,6 +3,7 @@ $(function () {
function () { function () {
$.getScript(this.href); $.getScript(this.href);
history.pushState(null, document.title, this.href); history.pushState(null, document.title, this.href);
history_edited = true;
return false; return false;
} }
); );
@ -11,16 +12,20 @@ $(function () {
function () { function () {
$.getScript(this.href); $.getScript(this.href);
history.replaceState(null, document.title, this.href); history.replaceState(null, document.title, this.href);
history_edited = true;
return false; return false;
} }
); );
$('.form').live('submit', function () { $('.form').live('submit', function () {
$.post(this.action, $(this).serialize(), null, 'script'); $.post(this.action, $(this).serialize(), null, 'script');
history_edited = true;
return false; return false;
}); });
$(window).bind("popstate", function () { $(window).bind("popstate", function () {
if (history_edited) {
$.getScript(location.href); $.getScript(location.href);
}
}); });
}); });