【发布时间】:2012-02-05 17:49:30
【问题描述】:
我使用了 jquery 布局,并且在该布局中我使用了拖放。但我不明白为什么可放置元素没有在放置区域中拖动。我用它来拖动但无法成功
jQuery(function() {
jQuery(".component").draggable({
//use a helper-clone that is append to 'body' so is not 'contained'
//by a pane
helper: function () {
return jQuery(this).clone().appendTo('body')
.css({'zIndex':5,}).show();
},
cursor: 'move'
});
jQuery('.ui-layout-center').droppable({
accept: '.component',
drop: function (event, ui) {
jQuery(this).append(jQuery(ui.draggable).clone());
}
});
});
我的html页面是这样的..
<div class="ui-layout-south">
<button onclick="myLayout.toggle('north')">Toggle North Pane</button>
</div>
<div class="ui-layout-east"><span>Components</span>
<div class="component" style="width: 30px; border: 2px solid #CCC;
background: #009; padding: 10px;"></div>
<p><button onclick="myLayout.close('east')">Close Me</button></p>
</div>
<div class="ui-layout-center">
</div>
【问题讨论】:
-
您的代码正在运行。看到这个小提琴jsfiddle.net/WpRTc
-
不,它没有按要求工作。在可放置区域中它没有再次拖动。