Skip to content

Instantly share code, notes, and snippets.

@cwmanning
Created June 27, 2012 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwmanning/3005229 to your computer and use it in GitHub Desktop.
Save cwmanning/3005229 to your computer and use it in GitHub Desktop.
loadBlogPage
/**
* Load 'blog' card (layer 0).
*/
loadBlogPage: function(path) {
//resets the nav to home so no subsections are highlighted
this.updateNavigation();
if(this.DEBUG) {console.log('Router: Load blog: ', path);}
PubSub.trigger('loadBlog:router', path);
// Destroy old blog cards.
/*
if(this.blog) {
this.blog.destroy(true);
this.blog = null;
}
*/
// If cards are in the DOM, fade them out and remove.
if(this.cards || this.blog) {
// Display loader.
this.alert.showLoader(this.LOADING_MESSAGE);
// Fetch blog page.
this.fetchData(path,
// Successful ajax call.
$.proxy(function(transport) {
// Hide the loader.
this.alert.hideLoader();
// Create new blog view with html fragment.
/*
this.blog = new BlogView({
htmlFrag: transport
});
*/
if (this.cards) {
this.cards.hide(true, $.proxy(function() {
// Create new blog view with html fragment.
this.blog = new BlogView({
htmlFrag: transport
});
this.blog.show(true, $.proxy(function() {
// Destroy the cards and the instance.
this.cards.destroy(true);
this.cards = null;
}, this));
}, this));
} else if (this.blog) {
console.log('BLOG TO BLOG')
this.blog.hide(true, $.proxy(function() {
this.blog.destroy(true);
this.blog = null;
this.blog = new BlogView({
htmlFrag: transport
});
this.blog.show(true);
}, this));
}
}, this)
);
} else {
this.blog = new BlogView();
}
PubSub.trigger('close:overlay', null, true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment