fix to "backing up" to homepage
This commit is contained in:
parent
8098886f01
commit
765dee9459
11
pagify.js
11
pagify.js
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue