jQuery UI 可选择 - 使多选默认
我需要默认提供多项选择,这样用户就不必按住 ctrl。希望得到一些帮助,谢谢。
I need to make multiple selection available by default, so the user doesn't have to hold ctrl. Would appreciate some help with this, thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您想使用 selectable ,您可能需要将元键与 mousedown 事件结合使用。 这里已经有一场争论,我刚刚在谷歌搜索时发现。
If you want to use selectable , you might want to use bind meta key with mousedown event. There's already a debate going down here , i just found when i googled.
好吧,如果你想修改可选代码,请在顶部的选项对象中添加一个选项(我称之为 multi_no_key,默认为 false)。
然后,查找声明 var doSelect 的位置,它最初看起来像这样
并将其更改为此
在同一个 _mouseStart 方法中,查找以下代码
并更改条件以检查 multi_no_key 的选项
我测试了这个,它对我来说效果很好。以下是可选js文件的全部内容(版本1.8.12)
Well, if you want to modify the selectable code, add an option to the options object at the top (I called mine multi_no_key, and defaulted to false).
Then, look for where var doSelect is declared, it originally looks like this
And change it to this
In that same _mouseStart method, look for the following code
And change the conditional to check the option for multi_no_key
I tested this and it worked well for me. Below is the entire contents of the selectable js file (version 1.8.12)
我曾经需要类似的东西。
这是一个关于如何做到这一点的很好的例子。我想它可能会给你一些想法。
http://www.joelanman.com/static/examples/multiple_selection/
这里是教程链接以及
http:// /www.joelanman.com/2009/03/simple-multiple-selection-with-checkbox-lists-and-jquery/
i needed something like it once.
Here is a nice example about how to do it. I think it may give you some ideas.
http://www.joelanman.com/static/examples/multiple_selection/
Here is the tutorial link as well
http://www.joelanman.com/2009/03/simple-multiple-selection-with-checkbox-lists-and-jquery/
老实说,我只是在 jqui 脚本上对“c.metaKey”进行了查找/替换,并将其替换为“true /*edited*/”...肮脏,但有效。
honestly, I just did a find/replace for 'c.metaKey' and replaced it with 'true /* edited */' on the jqui script... Dirty, but effective.