jquery布局和动态可拖动div问题

发布于 2024-10-08 03:23:46 字数 984 浏览 0 评论 0原文

我正在使用 jquery 布局插件,并遇到以下情况,但找不到解决方案。 如何通过将 div 拖动到底部边框之外来永久增加中心窗格的大小。

我有一个左窗格和一个中心窗格。我动态生成div 当用户单击左侧窗格时。 div 已生成并 落在中央窗格上。 div 可拖动且可调整大小。 通过在可见中心上拖动和调整大小,一切正常 区域。当我将 div 拖到底部之外时,滚动条就会打开 出现中心窗格,并且中心窗格似乎延伸到 适应拖动的 div 的新位置。但当我尝试的那一刻 要调整 div 大小或添加另一个 div,它会跳转到 div 并重置滚动条。我检查了中心 div 高度 firebug 初始化时它保持相同的高度 即使将新的 div 拖到底部之外也是如此。

这是测试页html代码。

只需完全复制/粘贴到 html 页面中即可。在左侧窗格中,单击“添加新”按钮将添加可拖动且可调整大小的新 div。

  1. 单击“添加新”
  2. 将新添加的 div 拖到中心窗格底部之外。
  3. 中心窗格按预期显示滚动条。
  4. 如果您在 firebug 中检查中心 div 的高度,它不会改变
  5. 现在尝试通过拖动其手柄来调整新添加的 div 的大小
  6. 它跳到顶部并且中心框失去了滚动条。

我无法粘贴完整的 html 页面,因此这里是对此线程底部代码的引用 http://groups.google.com/group/jquery-ui -layout/browse_thread/thread/ca922aa44c0048ee

这是测试链接 http://jsfiddle.net/yZc63/

I am using jquery layout plugin and have the following situation that I cannot find a solution. How do I make the center pane increase its size permanently by dragging the div beyond the bottom border.

I have a left pane and a center pane. I dynamically generate div
when the user clicks on the left pane. The divs are generated and
dropped on the center pane. The divs are draggable and resizable.
Everything works fine with dragging and resizing on the visible center
area. The moment I drag the div beyond the bottom, the scroll bar on
the center pane appears and it seems the center pane is extending to
accommodate the new position of the dragged div. But the moment I try
to resize the div or add another div, it jumps to the top section of
the div and resets the scrollbars. I checked the center div height in
firebug and it remains at the same height when initialized
even after dragging the new div beyond the bottom.

Here is the test page html code.

Just copy/paste entirely into a html page. On the left pane, click on the "Add new" button will add new div that is draggable and resizable.

  1. Click on "Add new"
  2. Drag the newly added div beyond the bottom of the center pane.
  3. The center pane shows the scrollbar as it is suppose to.
  4. If you check the center div's height in firebug, it is not changing
  5. Now try resizing the newly added div by dragging its handle
  6. It jumps to the top and the center box loses its scrollbar.

I could not paste the complete html page so here is the reference to the code at the bottom of this thread
http://groups.google.com/group/jquery-ui-layout/browse_thread/thread/ca922aa44c0048ee

And here is the test link http://jsfiddle.net/yZc63/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

枉心 2024-10-15 03:23:46

我很惊讶以前没有人遇到过这种情况吗?即使没有布局插件,我的解决方案也不是很漂亮。为了在没有布局插件的情况下模拟页面,我必须使用 CSS 中的position:fixed 属性保留顶部和左侧窗格。而且根本没有中心 div。我将新的 div 直接添加到 html 的正文中。原因是我不想在浏览器滚动条顶部看到额外的滚动条。换句话说,当浏览器滚动条移动时,中心窗格应该滚动。我附上解决方案,以便您有一个想法。

如果我可以使用任何其他方法模拟以前的附加文件,即使没有布局插件,我也愿意接受任何解决方案。我附加的页面没有布局插件,但不确定这是否是唯一剩下的优雅解决方案。

您可以在这里查看解决方案 http://jsfiddle.net/c7wrT/

是将动态 div 直接添加到 html body 是一个好方法吗?

I am surprised no one has come across this situation before? Even without the layout plugin, my solution is not very pretty. In order to simulate the page without the layout plugin, I had to keep the top and the left pane using position:fixed property in css. And there is no center div at all. I add the new div directly to the body of the html. The reason is I don't want to see additional scrollbars on top the browser scrollbars. In other words the center pane should scroll when the browser scrollbars are moved. I am attaching the solution so you have an idea.

I am open to any solution even without the layout plugin if i can simulate the previous attached file using any other approach. i am attaching my page without the layout plugin but am not sure if that is the only elegant solution left.

You can check the solution here http://jsfiddle.net/c7wrT/

Is adding the dynamic div directly to the html body a good approach?

水晶透心 2024-10-15 03:23:46

我遇到了同样的情况,这个答案有帮助。
https://stackoverflow.com/a/33004821/2139859更新的小提琴: http://jsfiddle.net/bababalcksheep/yZc63/11 /

$(".removalbe-recom").draggable({
    appendTo: "body",
    helper: "clone",
    revert: "invalid",
    cursor: "move",
    containment: "document",
    zIndex: 10000,
    scroll:false,
    start: function (event, ui) {
    $(this).hide();
    },
    stop: function (event, ui) {
        $(this).show();
    }
});

I ran into same situation and this answer helped.
https://stackoverflow.com/a/33004821/2139859. Updated Fiddle: http://jsfiddle.net/bababalcksheep/yZc63/11/

$(".removalbe-recom").draggable({
    appendTo: "body",
    helper: "clone",
    revert: "invalid",
    cursor: "move",
    containment: "document",
    zIndex: 10000,
    scroll:false,
    start: function (event, ui) {
    $(this).hide();
    },
    stop: function (event, ui) {
        $(this).show();
    }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文