0

在我的包含无序列表的用户/索引视图中

<ul id="documents" data-update-url="<%= sort_documents_url %>">
  <% @documents.each do |document| %>
  <%= content_tag_for :li, document do %>
  <span class="handle">[drag]</span>
  <%= link_to h(document.title), document %>
  <%= link_to 'Delete', document, method: :delete, remote: true %>
  <% end %>
  <% end %>
</ul>

正如您在 ul 中看到的,我正在为每个模型渲染一个部分。渲染的 html 的 _documents.html.erb 部分第二次更新。

<ul id="documents" data-update-url="http://localhost:3000/documents/sort">
  <li class="document" id="document_4fc4db0cb6231417f300000c">
    <span class="handle">[drag]</span>
    <a href="/documents/4fc4db0cb6231417f300000c">Help</a>
    <a href="/documents/4fc4db0cb6231417f300000c" data-method="delete" data-remote="true" rel="nofollow">Delete</a>
</li>  <li class="document" id="document_4fc4db27b6231417f300000f">
    <span class="handle">[drag]</span>
    <a href="/documents/4fc4db27b6231417f300000f">adam</a>
    <a href="/documents/4fc4db27b6231417f300000f" data-method="delete" data-remote="true" rel="nofollow">Delete</a>
</li>  <li class="document" id="document_4fc4db2db6231417f3000010">
    <span class="handle">[drag]</span>
    <a href="/documents/4fc4db2db6231417f3000010">adam</a>
    <a href="/documents/4fc4db2db6231417f3000010" data-method="delete" data-remote="true" rel="nofollow">Delete</a>
</li>  <li class="document" id="document_4fc4dbaab6231417f3000015">
    <span class="handle">[drag]</span>
    <a href="/documents/4fc4dbaab6231417f3000015"></a>
    <a href="/documents/4fc4dbaab6231417f3000015" data-method="delete" data-remote="true" rel="nofollow">Delete</a>
</li></ul>

document.js.coffee jQuery ->

  $('#documents').sortable
    handle: '.handle'
    update: ->
      $.post($(this).data('update-url'), $(this).sortable('serialize'))
4

1 回答 1

2

您不能<div>直接在<ul>. 我敢打赌那是在抛弃剧本。

事实上,除了or中之外,你不能有任何东西。<li><ol><ul>

于 2012-05-29T13:30:53.937 回答