jQuery UI Droppable:如何使其生效?
在这个问题中,当鼠标移动时,可拖动对象是动态创建的输入要拖动的元素。
我想做同样的事情,但是使用 droppables :决定是否仅当拖动的元素到达其上方时才使元素可放置。我确信这是可能的,但经过一番研究后,我无法做到。
我尝试过类似的事情,但失败了:
jQuery.fn.liveDroppable = function (opts) {
this.live("mouseover", function() {
if (!$(this).data("livedropinit")) {
$(this).data("livedropinit", true).droppable(opts);
$(this).trigger('dropover');
}
});
};
In this question, draggables are created on the fly, when the mouse enters the element to drag.
I'd like to do the same kind of thing, but with droppables : decides whether to make the element droppable only when the dragged element arrives over it. I'm sure it's possible but after a bit of research, I couldn't make it.
I tried things like this, but failed:
jQuery.fn.liveDroppable = function (opts) {
this.live("mouseover", function() {
if (!$(this).data("livedropinit")) {
$(this).data("livedropinit", true).droppable(opts);
$(this).trigger('dropover');
}
});
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我通过使用 这篇文章< 中描述的方法将其绑定到 JQuery 来实现此目的/a> 可拖动。唯一的问题是,我目前正在调查的嵌套 droppable 似乎存在问题。这是修改后的版本。我不得不将其更改为“mouseenter”。
现在不要这样称呼它:
...只需使用:
I got this to work by binding it to JQuery using the methods described on this post for draggable. The only problem is that it seems to have an issue on nested droppables which I am currently investigating. Here's the modified version. I had to change it to "mouseenter".
Now instead of calling it like:
...just use:
这对你有用吗?这是 .hover();功能。不确定你是否已经尝试过。
http://api.jquery.com/hover/
Would this work for you? It's the .hover(); function. Not sure if you've tried it yet.
http://api.jquery.com/hover/