ユーザーがドラッグを開始するとすぐに、ドラッグ可能な要素の位置を変更する必要があるという奇妙な状況があります。そのため、ドラッグ可能な要素の開始イベント ハンドラー中に、位置を設定しようとしています。位置を変更した後、JavaScript エラーが発生するようなことをしない限り、位置の変更に応答しません。これは奇妙です。次に例を示します。
<html>
<head>
<title>Drag reposition test</title>
<script type="text/javascript" src="js/css_browser_selector.js"></script>
<script type="text/javascript" src="development-bundle/jquery-1.3.2.js"></script>
<script type="text/javascript" src="development-bundle/ui/jquery-ui-1.7.1.custom.js"></script> <!-- Includes JQuery UI Draggable. -->
<style type="text/css">
#draggable { width: 150px; height: 150px; padding: 0.5em; }
</style>
<script type="text/javascript">
$(function() {
$("#initialdragger").draggable({
start: function(e, ui) {
$('#initialdragger').css('top', 400);
x = y; // Javascript error, which weirdly causes a redraw.
}
});
});
</script>
</head>
<body>
<div id="initialdragger" class="ui-widget-content" style="border-width: 1px; border-color: black; background-color: orange; width: 300px">
<p>Drag me around</p>
</div>
</body>
</html>
このコンテキストで合法的に再描画を発生させるにはどうすればよいですか? JQuery の hide() と show() は機能せず、これらのメソッドも機能しません。