i implement following code in rails application.js file. when user clicks on link, view reloads complete list of reviewers instead of first 4:
$(document).ready(function(){ $("#more_reviewers").click(function(e){ $("#reviewer_list").html('<%= escape_javascript(render "restaurants/restaurant_reviewer_list", :venue => @restaurant, :limit => @restaurant.reviews.count) %>'); }); });
problem: instead of showing me list, code returns rails code text. on screen, instead of seeing list of users, see:
'<%= escape_javascript(render "restaurants/restaurant_reviewer_list", :venue => @restaurant, :limit => @restaurant.reviews.count) %>'
this going simple 1 - , i'll appreciate it.
in addition thomas' explanation client-side , server-side , assuming don't have to make request server: easiest put partial in hidden div in view , use jquery display it.
show.html.erb:
<div style="display:none;" id="hidden_div"> <%= render "restaurants/restaurant_reviewer_list", :venue => @restaurant, :limit => @restaurant.reviews.count %> </div>
application.js:
$(document).ready(function(){ $("#more_reviewers").click(function(e){ $("#hidden_div").show(); }); });
Comments
Post a Comment