From 765dee945927d5dd9bd2ea945812d77d0bdbf450 Mon Sep 17 00:00:00 2001 From: Chris Polis Date: Thu, 29 Sep 2011 21:33:26 -0700 Subject: [PATCH] fix to "backing up" to homepage --- pagify.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pagify.js b/pagify.js index 051f1ce..10c0a33 100644 --- a/pagify.js +++ b/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'); } }