javascript Jquery UI 可排序不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19725089/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jquery UI sortable not working
提问by Mark Pross
I've been trying to get the sortable function to work, searched a lot of articles but so far no success.
我一直在尝试使 sortable 功能起作用,搜索了很多文章,但到目前为止都没有成功。
The basics are just get the simple ul to become sortable like the nice example on jqueryui.com The problem being, i'm doing everything as suggested but it's just ignoring me.
基础只是让简单的 ul 变得可排序,就像 jqueryui.com 上的好例子问题是,我正在按照建议做所有事情,但它只是无视我。
here is what i currently have: http://jsfiddle.net/N63qQ/
这是我目前拥有的:http: //jsfiddle.net/N63qQ/
html:
html:
<ul id="sortable">
<li id="item_1">bla</li>
<li id="item_2">bla</li>
</ul>
js in the onload(and no onload is not in fact the problem)
js 在 onload(实际上没有 onload 不是问题)
$(function () {
$('#sortable').droppable({
tolerance: 'touch',
drop: function () {
alert('delete!');
}
});
$('#item').sortable();
});
EDIT: ah got it, was using a wrong jquery ui lib
编辑:啊明白了,使用了错误的 jquery ui lib
回答by Maxim Ershov
it should be sortable, not dropable. Here is your code http://jsfiddle.net/N63qQ/4/
它应该是可排序的,而不是可丢弃的。这是你的代码http://jsfiddle.net/N63qQ/4/
$(function () {
$('#sortable').sortable({
tolerance: 'touch',
drop: function () {
alert('delete!');
}
});
$('#item').sortable();
});
You also forgot to include Jquery UI in your code
您还忘记在代码中包含 Jquery UI