【问题标题】:save jquery drag and drop position relative to parent DIV?保存相对于父DIV的jquery拖放位置?
【发布时间】:2012-03-21 12:40:41
【问题描述】:

我正在使用 php 和 jquery-ui 来保存拖放位置。我的问题是它的保存顶部,左侧位置在更宽的屏幕上查看时会有所不同!

如何将实际位置保存到父元素?

【问题讨论】:

    标签: php jquery jquery-ui position draggable


    【解决方案1】:

    对于这种问题,我做了类似的事情:

    我使用

    将位置保存在数据库中
    parent = $('#theParentElement');
    positionX = (parseInt(ui.draggable.css('left'))) / parent.width();
    positionY = (parseInt(ui.draggable.css('top'))) / parent.height();
    

    然后当我在另一个客户端屏幕上从 db 设置位置时。

    $("#elmtToPosition").css({
            'left':positionX * parent.width(),
            'top':positionY * parent.height()
            }); 
    

    它对我有用,尝试适应它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-10
      • 1970-01-01
      • 2015-12-06
      • 1970-01-01
      • 1970-01-01
      • 2013-05-14
      • 2011-08-17
      相关资源
      最近更新 更多