Created
April 13, 2010 15:00
-
-
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.
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
$(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; | |
}); | |
}); |
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
<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