我很抱歉,如果这是超级简单但我只是看不出有什么问题,但更新事件(或我尝试过的任何事件)都没有以可排序方式触发。我尝试使用它们提供的基本示例创建一个简单的测试,但它仍然失败。有人可以帮忙吗?
HTML:
<ol class='example'>
<li>First</li>
<li>Second</li>
<li>Third</li>
</ol>
我的main.js
$(document).ready(function() {
$("ol.example").sortable({
update:function(event, ui){
alert("in the update");
}
});
})
我发现的最近的公开问题是Why is sort the only event firing for jQuery UI .sortable()?。但这仍然没有帮助。我也尝试过对事件也使用绑定也失败了。我正在使用jquery版本1.9.1以防万一。
答案 0 :(得分:2)
我认为你在jQuery librairies的包含方面存在问题,请尝试替换:
<script type="text/javascript" src="jslib/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="jslib/jquery-ui.min.js"></script>
<script type="text/javascript" src="jslib/jquery-sortable.js"></script>
通过:
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
如果有效,请验证jslib文件夹中的库。
完整的工作代码:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<head>
<body>
<ol class='example'>
<li>First</li>
<li>Second</li>
<li>Third</li>
</ol>
<script>
$(document).ready(function() {
$("ol.example").sortable({
update:function(event, ui){
alert("in the update");
}
});
});
</script>
</body>
</html>