I am following this tutorial: https://github.com/amatsuda/kaminari/wiki/How-To:-Create-Infinite-Scrolling-with-jQuery
So far everything works great, but I am stuck at the last part of the tutorial.
The content in my show.html.haml gets rendered like this:
- @search_results.each do |search_result|
=render 'search_result', :search_result=>search_result
The problem is that I have no idea how to translate that to show.js.erb , currently I have (mimicked from the tutorial)
$(".offers").append("<%= escape_javascript(render(@search_results)) %>");
but that throws errors. (undefined method `model_name' for Hash:Class)
in my controller, search results is defined as:
@search_results = Kaminari.paginate_array(all_search_results).page(params[:page]).per(6)
all_search_results is an array that gets filled with stuff from another model.
<%= @search_results.map {|search_result| render('search_result.html', :search_result => search_result)}.to_json.html_safe %>
做到了
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.