将 LI 从正常的未排序 UL 列表克隆到可排序列表
我有一个未排序的 UL 列表,显示搜索结果。我希望用户能够单击所需的 LI,并将整个 LI 复制到 jQuery UI 可排序列表,在选择所需数量的项目后,他们可以在其中进行排序和排序。所讨论的 LI 由跨度、图像和包含 JSON 的隐藏字段组成。
HTML:
<li onclick="cloneToSortable(this);"><img src="item.jpg"> <span>Result Name</span> <input type="hidden" name="0arr" value='{"field1":"val1","field2":"val2","field3":"val3"}' /></li>
<li onclick="cloneToSortable(this);"><img src="item.jpg"> <span>Result Name</span> <input type="hidden" name="1arr" value='{"field1":"val1","field2":"val2","field3":"val3"}' /></li>
<li onclick="cloneToSortable(this);"><img src="item.jpg"> <span>Result Name</span> <input type="hidden" name="2arr" value='{"field1":"val1","field2":"val2","field3":"val3"}' /></li>
<li onclick="cloneToSortable(this);"><img src="item.jpg"> <span>Result Name</span> <input type="hidden" name="3arr" value='{"field1":"val1","field2":"val2","field3":"val3"}' /></li>
Javascript:
function cloneToSortable(li)
{
$('#itemSearchList ul li:eq('+$(li).index()+')').clone().appendTo('#sortable');
}
这没有给我任何错误消息,但在可排序列表中也没有给我任何信息。有什么想法为什么吗?
I have an unsorted UL list displaying search results. I want the user to be able to click their required LI and have the entire LI copy to a jQuery UI sortable list where they can order and sort after selecting the required amount of items. The LI in question is formated with spans, images and a hidden field containing a JSON.
HTML:
<li onclick="cloneToSortable(this);"><img src="item.jpg"> <span>Result Name</span> <input type="hidden" name="0arr" value='{"field1":"val1","field2":"val2","field3":"val3"}' /></li>
<li onclick="cloneToSortable(this);"><img src="item.jpg"> <span>Result Name</span> <input type="hidden" name="1arr" value='{"field1":"val1","field2":"val2","field3":"val3"}' /></li>
<li onclick="cloneToSortable(this);"><img src="item.jpg"> <span>Result Name</span> <input type="hidden" name="2arr" value='{"field1":"val1","field2":"val2","field3":"val3"}' /></li>
<li onclick="cloneToSortable(this);"><img src="item.jpg"> <span>Result Name</span> <input type="hidden" name="3arr" value='{"field1":"val1","field2":"val2","field3":"val3"}' /></li>
Javascript:
function cloneToSortable(li)
{
$('#itemSearchList ul li:eq('+$(li).index()+')').clone().appendTo('#sortable');
}
This gives me no error message but it also gives me nothing in the sortable list either. Any ideas why??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正是我解决这个问题所需要的
Was exactly what I needed for this problem