我在使用jQuery UI的拖/放的问题。我需要拖动元素加入到含有内可投放区域的iframe。当我在左边拖动项目拖放到的iframe,它没有工作,我的预期。这看起来正是这种小提琴:
JS
$('#my-frame').load(function () {
$('.draggable').draggable({
appendTo: 'body',
helper: 'clone',
iframeFix: true,
revert: 'invalid',
connectToSortable: $('#my-frame').contents().find('.sortable'),
cursorAt: { top: 10, left: 0 },
drag: function(event,ui){
console.log(ui.offset);
}
});
$('#my-frame').contents().find('.sortable').sortable({
iframeFix: true,
cursorAt: { top: 0, left: 0 }
});
});
$('.draggable').on('dragstop',autoResize);
function autoResize(){
var newheight;
if(document.getElementById){
newheight=document.getElementById('my-frame').contentWindow.document .body.scrollHeight;
}
newheight=newheight+100;
$('#my-frame').css('height',newheight);
}
你能帮我解决这一问题?谢谢
好了问题来在自己的iframe的宽度。你可以把“PX”比“%”吗?
看看这个小提琴,偏移量是良好的:
#my-frame {
width: 500px;
height: 300px;
position: absolute;
right: 0px;
}
我有同样的问题,唯一的解决办法,我发现是在这里:http://maxazan.github.io/jquery-ui-droppable-iframe/
只是链接的js文件,它应该工作的绝对完美