有什么办法可以去掉
我有一个要求,其中我有一个容器 div,其中包含 3 个
,其上附加了 Dragsort 结构,类似于<div id="container">
<ul id="list1">
<li><div>a</div></li>
<li><div>a</div></li>
<li><div>a</div></li>
<li><div>a</div></li>
</ul>
<ul id="list2">
<li><div>b</div></li>
<li><div>b</div></li>
<li><div>b</div></li>
<li><div>b</div></li>
</ul>
<ul id="list3">
<li><div>c</div></li>
<li><div>c</div></li>
<li><div>c</div></li>
<li><div>c</div></li>
</ul>
</div>
要求:
这些项目被拖动并放置在其中。放在这些列表之间。但是项目不应该从容器div中取出(视觉上不是)当有人试图将项目拖出容器div时,有什么方法可以将鼠标与项目分离,
就像有
containment: "#containment-wrapper" in jquery .draggable(
i have a requirement in which i have a container div that contains 3 <ul>
on which dragsort is attached stucture is comething like
<div id="container">
<ul id="list1">
<li><div>a</div></li>
<li><div>a</div></li>
<li><div>a</div></li>
<li><div>a</div></li>
</ul>
<ul id="list2">
<li><div>b</div></li>
<li><div>b</div></li>
<li><div>b</div></li>
<li><div>b</div></li>
</ul>
<ul id="list3">
<li><div>c</div></li>
<li><div>c</div></li>
<li><div>c</div></li>
<li><div>c</div></li>
</ul>
</div>
Requirement:
these item are dragged & drop in between these lists . but item should not be taken out of the container div (visually not) is there any way to detach the mouse from the item when somone is trying to drag item out of the container div
like there is
containment: "#containment-wrapper" in jquery .draggable(
reference: http://jqueryui.com/demos/draggable/#constrain-movement
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您指的是 jQuery List DragSort,它被编码为包含拖动项目在容器内,但如果您不在列表之间拖动,则只能在 UL 内拖动项目。因此,要指定自定义容器,您需要修改代码。所以在代码中找到这个:
并替换为:
接下来找到这个:
并替换为:
现在像这样调用dragsort:
If you're referring to jQuery List DragSort, it is coded to contain the dragged item within a container but only inside UL if you're not dragging between lists. So to specify a custom container you will need to modify the code. So find this in the code:
And replace with:
Next find this:
And replace with this:
Now invoke dragsort like this:
您是否正在寻找这样的东西?:
HTML:
脚本:
CSS:
提示:
您可以使用 javascript 动态设置容器的宽度和高度。如果容器的子元素是绝对定位的,则可能会导致容器无法按其应有的方式“拉伸”。这就是为什么我们需要设置宽度和高度。
希望这对你有帮助,如果我的英语有点生疏,抱歉。
Are you looking for something like this?:
HTML:
SCRIPT:
CSS:
TIP:
You could set width and height on the containment dynamically with javascript. If the child elements of the containment are absolute positioned it could result that the containment doesn't "stretch" as it should. This is why we need to set width and height.
Hope this helps you and sorry if my English is a little rusty.