我只希望用户可以选择将项目从下表(#sortable2)移动到上表(#sortable1)。
我认为这与{'connectWith':'.connectedSortable',
我试过了:{'connectWith':'#sortable1, .connectedSortable',
但它不起作用..
$(document).ready(function(){
jQuery('#sortable1, #sortable2')
.sortable(
{'connectWith':'.connectedSortable',
'dropOnEmpty':true,
'scroll':true,
items: "li:not(.emptyMessage)",
receive: function(event, ui) {
//hide empty message on receiver
$('li.emptyMessage', this).hide();
//show empty message on sender if applicable
if($('li:not(.emptyMessage)', ui.sender).length == 0){
$('li.emptyMessage', ui.sender).show();
} else {
$('li.emptyMessage', ui.sender).hide();
}
}
});
});
这是我的index.html.erb
:
<html>
<body>
<ul id="sortable1" class="connectedSortable">
<% @tasks_worker_todo.each do |task| %>
<li class="ui-state-default">
<%= best_in_place task, :done, :classes => 'highlight_on_success', type: :checkbox, collection: %w[No Yes] %> |
<%= task.admin_mail %> |
<%= task.task %>
</li>
<% end %>
</ul>
<br><br>
<ul id="sortable2" class="connectedSortable">
<% @tasks_worker_done.each do |task| %>
<li class="ui-state-highlight">
<%= best_in_place task, :done,:classes => 'highlight_on_success', type: :checkbox, collection: %w[No Yes] %> |
<%= task.admin_mail %> |
<%= task.task %>
</li>
<% end %>
</ul>
</body>
</html>
请帮忙。