fix to "backing up" to homepage

This commit is contained in:
Chris Polis 2011-09-29 21:33:26 -07:00
parent 8098886f01
commit 765dee9459

View file

@ -15,7 +15,6 @@
pages: [],
default: null,
animation: 'show',
onChange: function (page) {},
cache: false
};
this.settings = $.extend({}, this.defaults, options);
@ -23,18 +22,20 @@
// Run after loading if caching, otherwise run immediately
var runAfterLoading = function() {
self.switchPage = function(page) {
page = page || window.location.hash.replace('#','');
// Page is selected from: passed in value, window.location, default
if(!page) {
page = window.location.hash.replace('#','') || self.settings.default;
}
// Load page content from cache
if(self.settings.cache) {
$(self).hide().html(self.pages[page])[self.settings.animation]();
self.settings.onChange(page);
// Fetch page content
} else {
$.get(page+'.html', function(content) {
$(self).hide().html(content)[self.settings.animation]();
self.settings.onChange(page);
}, 'text');
}
}