[英]uncaught error on infinite scroll with kaminari Rails, why? simple
我對JS真的很陌生,所以我不知道問題的根源是什么,但是我遇到了我認為是相對簡單的問題。 我正在嘗試實現一個無窮滾動功能, 如此處的演示 。 我相信我已經完全按照規定實施了它,但是我在Chrome控制台中遇到了以下錯誤。
'Uncaught Type Error: undefined is not a function'
我認為這是阻止無限滾動工作的原因。 它似乎發生在第3行。
這是咖啡稿
$(document).ready ->
$("#entries .pages").infinitescroll
navSelector: "nav.pagination"
nextSelector: "nav.pagination a[rel=next]"
itemSelector: "#entries tr.photo"
rejected.js.erb
$("#entries").append("<tbody class='page'><%= escape_javascript(render(entries)) %></tbody>");
rejected.html.erb
<h1>Rejected</h1>
<table id="entries">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Photo</th>
<th>Submitted</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody class="page">
<%= render partial: 'admin/entries/entries' %>
</tbody>
</table>
<%= paginate entries %>
和部分_entries.html> erb
<% if entries.any? %>
<% entries.each do |photo| %>
<tr id='photo_<%= photo.id %>' class='photo'>
<td><%= photo.firstname %></td>
<td><%= photo.email %></td>
<td><%= image_tag photo.attachment.url %></td>
<td><%= time_helper(photo.created_at) %></td>
<% if photo.workflow_state == 'rejected' %>
<td><%= link_to "Approve", (toggle_approve_field_admin_entry_path(photo, params.except(:controller, :action))), :remote => true %></td>
<td><%= link_to 'Destroy', admin_entry_path(photo), method: :delete, data: { confirm: 'Are you sure?' }, :remote => true %></td>
<% elsif photo.workflow_state == 'approved' %>
<td><%= link_to "Reject", (toggle_reject_field_admin_entry_path(photo, params.except(:controller, :action))), :remote => true %></td>
<% else %>
<td><%= link_to "Approve", (toggle_approve_field_admin_entry_path(photo, params.except(:controller, :action))), :remote => true %></td>
<td><%= link_to "Reject", (toggle_reject_field_admin_entry_path(photo, params.except(:controller, :action))), :remote => true %></td>
<% end %>
</tr>
<% end %>
<% end %>
有人對這為什么不起作用有任何線索嗎?
更新:現在我沒有錯誤。 我稀薄的問題是現在的選擇器:
這部分,要求更多的東西
<tr id='photo_<%= photo.id %>' class='photo'>
與該匹配器不匹配
itemSelector: "#entries tr.photo"
但是由於id是動態的,如何將其插入?
“未定義不是函數”表示您試圖調用不存在的內容。 我敢打賭,這個infinitescroll
功能; 如果您沒有在項目中包含無限滾動插件 (或尚未正確加載),那么它將是未定義的,並且會收到上面的錯誤。 確保已將文件包含在正確的位置,然后從瀏覽器控制台檢查資產管道已將其包含在頁面中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.