jQuery UI的拖动与iframe的错误可投放位置手柄

问题描述 投票:0回答:2

我在使用jQuery UI的拖/放的问题。我需要拖动元素加入到含有内可投放区域的iframe。当我在左边拖动项目拖放到的iframe,它没有工作,我的预期。这看起来正是这种小提琴:

jsfiddle.net/8Jwxv/66/

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);
}

你能帮我解决这一问题?谢谢

jquery jquery-ui-draggable jquery-ui-droppable
2个回答
0
投票

好了问题来在自己的iframe的宽度。你可以把“PX”比“%”吗?

看看这个小提琴,偏移量是良好的:

http://jsfiddle.net/8Jwxv/68/

#my-frame {
    width: 500px;
    height: 300px;
    position: absolute;
    right: 0px;
}

-1
投票

我有同样的问题,唯一的解决办法,我发现是在这里:http://maxazan.github.io/jquery-ui-droppable-iframe/

只是链接的js文件,它应该工作的绝对完美

© www.soinside.com 2019 - 2024. All rights reserved.