从“单击”动态更改 jqueryui 手风琴事件处理程序到“鼠标悬停”

发布于 2024-10-06 05:03:02 字数 331 浏览 1 评论 0原文

我遇到一种情况,我希望能够将列表中的项目拖到手风琴中的目标中。但是,我拖动到的项目可能位于另一个面板(未打开的面板)中。

为了促进这一点,我想在拖动开始后动态地将手风琴的事件从单击更改为鼠标悬停。拖动完成后,我将切换回单击。这将使用户将鼠标悬停在关闭的面板上,使其打开,此时他们可以放下项目。完成后,我希望他们通过单击来打开面板。

这可能吗?我尝试过使用设置器:

$( ".selector" ).accordion( "option", "event", 'mouseover' );

但它似乎并没有真正改变事件的动态。我发现有人提到这可能不受支持。如果没有,有谁知道我该怎么做?

I have a situation where I would like to be able to drag an item from a list into a target in an accordion. However, the item that I am dragging to might be in another panel (one that isn't open).

In order to facilitate this, I would like to dynamically change the accordion's event from click to mouseover once the drag starts. After the drag is complete, I'll switch back to click. This will let the user hover over the closed panel, causing it to open at which point they can drop the item. Once they're done, I'd prefer that they use a click to open the panel.

Is this possible? I've tried using the setter:

$( ".selector" ).accordion( "option", "event", 'mouseover' );

but it doesn't seem to actually change the event on the fly. I found some mention that this might not be supported. If not, does anyone know how I might do this?

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

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

发布评论

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

评论(2

网名女生简单气质 2024-10-13 05:03:02

您需要在元素拖动事件处理程序中使用设置器。类似以下内容应该有效:

$('li.draggable').mousedown(function(){

    $( "div.accordion" ).accordion( "option", "event", 'mouseover' );

}).mouseup(function(){

    $( "div.accordion" ).accordion( "option", "event", 'click' );

});

您需要根据您的特定情况定制选择器。当用户单击可拖动元素时,mousedown 事件处理程序将触发,将手风琴的 event 设置更改为“mouseover”;当释放单击并结束拖动时,手风琴的 event 设置将恢复为“单击”。

You need to use the setter in the element-drag event-handler. Something like the following should work:

$('li.draggable').mousedown(function(){

    $( "div.accordion" ).accordion( "option", "event", 'mouseover' );

}).mouseup(function(){

    $( "div.accordion" ).accordion( "option", "event", 'click' );

});

You'll need to tailor the selectors to your particular case. The mousedown event-handler will trigger when the user clicks down on the draggable element, changing the accordion's event setting to 'mouseover'; when the click is released, ending the drag, the accordion's event setting gets reverted to 'click'.

初雪 2024-10-13 05:03:02

好吧,看起来这实际上是一个错误。应该在1.9中解决。

JqueryUI 错误 6740

OK, looks like this was actually a bug. Should be resolved in 1.9.

JqueryUI bug 6740

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