添加到Jquery-ui可排序列表 [英] Add to Jquery-ui sortable list

查看:158
本文介绍了添加到Jquery-ui可排序列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关 Jquery-UI可排序列表的简单问题

我做过:

<div id="adder">
<input type="text" name="add1" /><br />
<input class='btn' type='submit' value='Submit' />
</div>

如何使用它来添加用户输入到jquery-ui可排序列表末尾的内容?

How can I use this to add what the user enters to the end of the jquery-ui sortable list?

推荐答案

据推测,您只需将文本包装在带有 ui类的LI中-state-default 并将其插入可排序的UL元素中。然后,您需要刷新 sortable以使新插入的元素被识别:

Presumably, you would just take the text, wrap it in an LI with the class ui-state-default and insert it into the sortable UL element. You will then need to refresh the sortable to cause the newly inserted element to be recognised:

$(".btn").click(function (e) {
    e.preventDefault();
    var text = $("input[name='add1']").val();
    var $li = $("<li class='ui-state-default'/>").text(text);
    $("#sortable").append($li);
    $("#sortable").sortable('refresh');
});

你可以在这里试试。

这篇关于添加到Jquery-ui可排序列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆