也许这是设计使然,但我希望手柄立即draggable
生效,而不是像目前发生的那样在第一次 mouseup 之后。
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/base/minified/jquery-ui.min.css" rel="stylesheet" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js"></script>
<script>
$(function () {
var handle = $("#handle");
handle.on("mousedown", function () {
// doesn't work
handle.draggable();
});
// works
handle.draggable();
});
</script>
</head>
<body>
<div style="width: 400px; height: 400px; border: 2px solid gray; position: relative;">
<div id="handle" style="width: 50px; height: 50px; position: absolute; top: 100px; left: 100px; background-color: gray;"></div>
</div>
</body>
</html>