どのように私はjQueryのUIドラッグ可能な要素の開始イベントハンドラの間を有効にするCSSの位置変化を得ることができますか?

StackOverflow https://stackoverflow.com/questions/1105133

質問

私は、ユーザーがそれをドラッグを開始したとして、私は、すぐにドラッグ可能な要素の位置を変更する必要のある奇妙な状況があります。だから、ドラッグ可能な要素の開始イベントハンドラの間に、私は位置を設定しようとしています。それはない限り、位置の変化に対応しない - これは奇妙である - 私は位置を変更した後、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の非表示()とshow()はどちらも行う動作しません。方法はします。

役に立ちましたか?

解決

私は、マウスダウンイベントが何をしたいあなたを得るでしょうバインディングと思います。

<script type="text/javascript">
    $(function() {
        $("#initialdragger").draggable();
        $('#initialdragger').bind("mousedown", function(e) {
            $(this).css('top', 400);
        });
    });
</script>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top