Created
June 6, 2014 02:32
-
-
Save aderaaij/842f1b8964146d4f5ffb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.get_page = function(options) { | |
// Merge passed options with defaults | |
var opts = $.extend({}, $.fn.get_page.defaults, options); | |
return this.each(function() { | |
$('#ajax-content').addClass('loading'); | |
$('body').addClass('loading'); | |
$.ajax({ | |
type: 'GET', | |
url: opts.feed, | |
dataType: 'json', | |
data: { | |
minRow: 1, | |
maxRow: 5 | |
}, | |
success: function( data ) { | |
opts.targetwrap.append( Mustache.to_html( opts.template, data ) ); | |
$('#ajax-content').removeClass('loading'); | |
$('body').removeClass('loading'); | |
$('body').addClass('is-active-page'); | |
document_title = data.title+' - Sumeramusic.com'; | |
document.title = document_title; | |
var state_obj = { post_id: data.id }; | |
history.pushState( state_obj, document_title, data.url ); | |
opts.aftersuccess(this); | |
} | |
}); | |
}); | |
}; | |
$.fn.get_page.defaults = { | |
feed: 'api/tourpage.json', | |
template: $('#tour-page-templ').html(), | |
targetwrap: $('body'), | |
aftersuccess: function() {} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment