Skip to content

Instantly share code, notes, and snippets.

@iMagesh
Created January 27, 2012 12:21
Show Gist options
  • Save iMagesh/1688533 to your computer and use it in GitHub Desktop.
Save iMagesh/1688533 to your computer and use it in GitHub Desktop.
Ajaxify will_paginate
function fetchParams(link){
var vars = [], hash;
var hashes = link.slice(link.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
$(function () {
$('.todo-pagination a').live('click', function (event) {
event.preventDefault();
var params = fetchParams(this.href);
$.ajax({url: "/casein/schedules/more_todos",type: 'get', data: {page: params["page"]}});
});
})
@iMagesh
Copy link
Author

iMagesh commented Jan 27, 2012

These are the jquery function that i used along with will_paginate plugin to ajaxify it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment