jQueryUI 默认多选并具有套索切换选定状态
我正在尝试实现一个类似比较图表的表格,除了我需要的一些功能更改之外,大量可选对象可以完美地工作。我发现这两个问题都在前面的问题中得到了解决,但都没有提供完整的解决方案。
这个问题解决了多重选择行为默认,但只说“我自己做的”而不提供任何内容。看看 selectable 的内部结构,我发现如果我使用 !event.metaKey 条件,我可能会得到我正在寻找的行为而不会遇到太多麻烦,但想知道是否有人有一个不涉及编辑的解决方案内部结构。
同样,此页面解决了我想要的套索切换效果,但我不确定在代码中,套索功能已更改,并且据报告脚本的其余部分(可排序功能)在 chrome 或 IE8 中不起作用(link)并且已经过时了,我不想依赖整个事情。
因此,如果有人能帮助我解决这两个问题,我将不胜感激。谢谢
[编辑] 格式化...
I'm trying to implement a comparison chart-like table, and a large list of selectable objects would work just perfectly, save for a few functionality changes that I need. I see that both of these have been addressed in previous questions, but neither of them provide complete solutions.
This question addressed the multiple select behavior by default, but only says 'I did it on my own' without providing anything. Looking at the internals of selectable, I see that if I play with the !event.metaKey condition I could probably get the behavior I'm looking for without too much trouble, but was wondering if anyone had a solution that didn't involve editing the internals.
Similarly, this page addresses the lasso toggle effect that I desired, but I'm not sure where in the code the lasso functionality was changed and as the rest of the script (the sortable functionality) is reported to not work in chrome or IE8 (link) and is outdated as this point, I'd rather not rely on the entire thing.
So if anyone could help me out with either of these, I'd appreciate it. Thanks
[Edit] Formatting...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我确信有更好的方法来做到这一点,但这是我在可选择的 js 文件中所做的。
对于始终多重选择:
我添加了一个选项“alwaysMulti”(默认为 false)。然后,我将
!event.metaKey
的三个实例替换为(!event.metaKey && !options.alwaysMulti)
以及event 的两个实例。 metaKey
与(event.metaKey || options.alwaysMulti)
。为了让选择套索切换所选状态,我从链接到的第二页找到了所需的更改。我还添加了一个选项“lassoToggle”(默认为 false)来触发此功能。在 _mouseDrag 中,有一个条件
if (hit)
,它会更改为以下内容:注意:多选的 event.metaKey 更改不在该代码示例中。
希望这对其他人有帮助!
I'm sure there's a better way to do this, but here's what I've did within the selectable js file.
For the always multi-selection:
I added an option 'alwaysMulti' (default false). Then I replaced the three instances of
!event.metaKey
with(!event.metaKey && !options.alwaysMulti)
and the two instances ofevent.metaKey
with(event.metaKey || options.alwaysMulti)
.To get the selection lasso to toggle the selected status, I found the changes I needed from the second page I linked to. I also added an option 'lassoToggle' (default false) to trigger this functionality. Within _mouseDrag, there is a condition
if (hit)
, it gets changed to the following:Note: The event.metaKey change for the multi-select isn't in that code sample.
Hopefully this helps someone else!