从“单击”动态更改 jqueryui 手风琴事件处理程序到“鼠标悬停”
我遇到一种情况,我希望能够将列表中的项目拖到手风琴中的目标中。但是,我拖动到的项目可能位于另一个面板(未打开的面板)中。
为了促进这一点,我想在拖动开始后动态地将手风琴的事件从单击更改为鼠标悬停。拖动完成后,我将切换回单击。这将使用户将鼠标悬停在关闭的面板上,使其打开,此时他们可以放下项目。完成后,我希望他们通过单击来打开面板。
这可能吗?我尝试过使用设置器:
$( ".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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要在元素拖动事件处理程序中使用设置器。类似以下内容应该有效:
您需要根据您的特定情况定制选择器。当用户单击可拖动元素时,
mousedown
事件处理程序将触发,将手风琴的event
设置更改为“mouseover”;当释放单击并结束拖动时,手风琴的event
设置将恢复为“单击”。You need to use the setter in the element-drag event-handler. Something like the following should work:
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'sevent
setting to 'mouseover'; when the click is released, ending the drag, the accordion'sevent
setting gets reverted to 'click'.好吧,看起来这实际上是一个错误。应该在1.9中解决。
JqueryUI 错误 6740
OK, looks like this was actually a bug. Should be resolved in 1.9.
JqueryUI bug 6740