Skip to content

Instantly share code, notes, and snippets.

@capndesign
Created April 13, 2010 15:00
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 capndesign/364708 to your computer and use it in GitHub Desktop.
Save capndesign/364708 to your computer and use it in GitHub Desktop.
A method for adding new entries to the bottom of an index with AJAX in Movable Type. It requires jQuery.
$(document).ready(function() {
var page = 1;
$('.load-posts').click(function() {
$('.article:last').after('<div id="ajax-loader">Loading Data</div>');
page++;
var contentUrl = '/cgi-bin/mt/mt-search.cgi?page=' + page;
if ($(this).attr('id') == 'category-posts') { contentUrl += '&IncludeBlogs=1&limit=20&category=' + catId + '&archive_type=Category'; }
if ($(this).attr('id') == 'index-posts') { contentUrl += '&IncludeBlogs=1,4&limit=20&archive_type=Index'; }
$.get(contentUrl, function(data) {
if (data != '') {
$('.article:last').after(data);
$('#ajax-loader').remove();
} else {
$('#load-posts').remove();
$('#ajax-loader').remove();
}
});
return false;
});
});
<mt:Unless name="request.archive_type">
<!-- Normal search template code goes here -->
<mt:Else>
<mt:SearchResults limit="20">
<mt:Include module="Entry Summary">
</mt:SearchResults>
</mt:Unless>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment