2010-11-28 2 views
1

J'utilise jquery pour paginer mon application de la même manière que facebook et twitter le font. Ce qui suit va charger les résultats "next" mais il charge toute la page html. Il semble qu'il ne répond pas au format.js. Qu'est-ce que je fais mal ici?will_paginate avec jquery: respond_to ne pas répondre à la requête js

Home Controller 

def index 
    @products = Product.paginate(:per_page => 2, :page => params[:page]) 
    respond_to do |format| 
    format.html # index.html.erb 
    format.js { render :template => '/products_home.html.erb' } # Prodcuts home partial 
    end 
end 

Jquery Javascript to execute AJAX 
$(function() { 
    $(".pagination a").live("click", function() { 
var pagination = $(this).parent(); 
    $(".pagination").html("Page is loading..."); 
$.get(this.href, function(data) { 
    $('#show').append(data); 
    alert('Load was performed.'); 
    pagination.hide(); 
}); 
    return false 
    }); 
}); 

Répondre

Questions connexes