【问题标题】:elements not dragging in jsPlumb元素没有在 jsPlumb 中拖动
【发布时间】:2013-04-18 20:58:18
【问题描述】:

使用 jsPlumb 进行拖放时出现问题。我使左侧 div 可拖动,但是当您尝试拖动它们时,只有线条移动,div 也不移动。 这是我的代码:

<html>
<head>
<title>Plumb Test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/jquery.jsPlumb-1.3.16-all-min.js "></script>
<script type="text/javascript">
$(document).ready(function(){
    jsPlumb.draggable($(".left"));
    jsPlumb.connect({source:"div1", target:"div2",
        paintStyle:{lineWidth:15,strokeStyle:'rgb(243,230,18)'},
        endpointStyle:{fillStyle:'rgb(243,229,0)'}
    });
    jsPlumb.connect({
        source:'div3',
        target:'div4',
        paintStyle:{ lineWidth:10, strokeStyle:'rgba(0, 0, 200, 0.5)' },
        anchors:["RightMiddle", "LeftMiddle"],
        endpoint:[ "Rectangle", { width:10, height:8 } ]
    });     
    jsPlumb.connect({
        source:'div2',
        target:'div3',
        paintStyle:{lineWidth:8, strokeStyle:'rgb(189,11,11)'},
        anchors:["BottomCenter", "TopCenter"],
        endpoint:"Rectangle"
    });     
    $("#div1").css("background-color","blue");
});
</script>
<style>
#div1, #div4{background-color:red;width:150px;height:150px;}
#div2, #div3{background-color:green;width:150px;height:150px;}
.left{float:left;}
.right{float:right;}
</style>
</head>

<body>
    <div id="div1" class="left">This is a test</div>
    <div id="div2" class="right">This is a div</div>
    <div id="div3" class="left">This is a test</div>
    <div id="div4" class="right">This is a div</div>
</body>
<html>

【问题讨论】:

    标签: jquery jquery-ui jsplumb


    【解决方案1】:

    要启用拖动,您的 Div 必须绝对定位。

     <style>
     #div1, #div4{background-color:red;width:150px;height:150px;position:absolute; }
     #div2, #div3{background-color:green;width:150px;height:150px; position:absolute;}
     </style>
    

    更多信息请查看 jsplumbs 文档。

    Your working fiddle

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多