【发布时间】:2015-08-17 11:07:44
【问题描述】:
我在主框架中有 droppable 元素,在 iframe 应用程序中有 sortable。我需要的是连接它们 - 能够将项目拖动到 iframe 的 sortable
这是我所做的: http://jsfiddle.net/w9L3eorx/1/
在iframe里面我有
<div class="content">
<div class="block">Foo</div>
<div class="block">Bar</div>
</div>
<script>
$('.content').sortable({
iframeFix: true,
placeholder: 'block-placeholder',
update: function (event, ui) {
// turn the dragged item into a "block"
ui.item.addClass('block');
}
});
</script>
主框架
<div class='items'>
<div class="one">One</div>
<div class="two">Two</div>
</div>
<iframe src="frame.html" id="frame" width="800" height="800"></iframe>
<script>
$('.items div').draggable({
helper: function(e) {
return $('<div>').addClass('block').text( $(e.target).text() );
},
iframeFix: true,
connectToSortable: $('.content', $("#frame")[0].contentDocument)
});
</script>
我看到了工作示例http://ma.rkusa.st/zepto-dnd/example.html。但它是在没有 jquery 的情况下构建的,并且不适用于 IE9
【问题讨论】:
标签: javascript jquery jquery-ui iframe jquery-ui-sortable