可通过可选文本进行排序

发布于 2024-09-30 07:25:52 字数 606 浏览 11 评论 0原文

是否可以拥有可排序的元素,但仍然允许用户复制/粘贴元素内的文本?

<div class="sortable">
   <div class="pseudo-sortable">Foo</div>
   <div class="pseudo-sortable">Bar</div>
   <div>other stuff that i don't care if a user 
        can't copy (maybe images or buttoms)</div>
</div>

我可以轻松做到:

$('.sortable').sortable({cancel: '.pseudo-sortable'});

这将允许我在浏览器中选择文本,并根据需要进行复制/粘贴。然而,这也使得该人无法拖/放。所以我想我想要的是从取消开始,但是如果鼠标在容器外移动一定距离,那么伪排序就不再被取消。这有道理吗?

如果这是不可能的,我的最后一个选择是应用一个触发器,在可排序和不可排序之间切换容器,以便它们可以选择文本,但我更愿意最小化 ui 点击次数。

Is it possible to be able to have sortable elements, but still allow users to copy/paste the text inside the elements?

<div class="sortable">
   <div class="pseudo-sortable">Foo</div>
   <div class="pseudo-sortable">Bar</div>
   <div>other stuff that i don't care if a user 
        can't copy (maybe images or buttoms)</div>
</div>

I can easily do:

$('.sortable').sortable({cancel: '.pseudo-sortable'});

This will allow me to select the text in the browser and copy/paste if I want. However, this also makes it so that the person can't drag/drop. So I think what I'd like is to start off with the cancel but if the mouse goes a certain distance outside the container, then the pseudo-sortables are no longer canceled. Does that make sense?

If this is not possible my last option would be to apply a trigger that switches containers between sortable and non-sortable, so that they can select the text, but I'd prefer to minimize ui clicks.

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

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

发布评论

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

评论(2

苦妄 2024-10-07 07:25:52

将文本放入 中怎么样?

HTML

<ul id="sortable">
    <li><span>Item 1</span></li>
    <li><span>Item 2</span></li>
    <li><span>Item 3</span></li>
    <li><span>Item 4</span></li>
    <li><span>Item 5</span></li>
    <li><span>Item 6</span></li>
    <li><span>Item 7</span></li>
</ul>

jQuery

$("#sortable").sortable({
    revert: true,
    cancel: "#sortable li span"
});

在这里试试:http://jsfiddle.net/6uXx8/

What about putting your text in a <span>?

HTML

<ul id="sortable">
    <li><span>Item 1</span></li>
    <li><span>Item 2</span></li>
    <li><span>Item 3</span></li>
    <li><span>Item 4</span></li>
    <li><span>Item 5</span></li>
    <li><span>Item 6</span></li>
    <li><span>Item 7</span></li>
</ul>

jQuery

$("#sortable").sortable({
    revert: true,
    cancel: "#sortable li span"
});

Try it here: http://jsfiddle.net/6uXx8/

独享拥抱 2024-10-07 07:25:52

尝试添加句柄。这个想法是,您只能从手柄开始拖动项目,例如,该项目可以是元素内的图标。

Try adding a handle. The idea is that you can only start dragging the item from the handle, which could be, for example, an icon inside the element.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文