jQuery 插件 asmSelect 不保留排序顺序
因此,我使用 asmSelect 插件来创建列表,但也尝试用它来编辑现有列表。 asmSelect 允许您在提交之前手动排序/排列所选选项。
我的问题是,每当我从数据库中获取用户排序列表并让 asmSelect 在我的页面上执行其操作时,默认情况下(因为它是多重选择)它只会按照选择中原始选项出现的顺序对所选选项进行排序。因此,根本不保留我的排序顺序...
还有其他人看到这个问题并有解决方案吗?
So, I'm using the asmSelect plugin to create lists, but also trying to use it to edit existing lists. asmSelect allows you to manually sort/arrange the selected options before submitting.
My problem is whenever I go and grab the user sorted list from the database and let asmSelect do its thing on my page, by default (because it's a multiple select) it just orders the selected options in whatever order the original options in the select appears. Therefore, not retaining my sorted order at all...
Anyone else seen this issue yet and have a solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我还尝试按照数据库中的顺序构建最初选择的列表。我最终更新了 asmselect。 在此处查看更新的 asmselect 代码和示例。
在我的 jsp 中:
I also tried to build the initially selected list in the order from the database. I ended-up updating asmselect. See updated asmselect code and example here.
In my jsp:
这里同样的问题。
就我而言,我注意到值从 0 到 11 的 12 个项目列表的排序方式为 0、1、10、11、2、3...我的意思是,作为字符串排序而不是数字顺序。也许有某种方法可以强制 asm-select 转换为数字或按数字顺序排序?
编辑:没关系,我试图使用“option_1”、“option_2”等字符串来订购它。如果用于排序的值不是有效的数字字符串,则会回退为字符串排序。
Kchau,您是否没有将订单存储在额外的字段中,或者使用数据库 id 字段来检测退出存储选项的订单?一旦存储了订单(或检测到,您喜欢什么),就需要为要订购的代码生成 rel 值。我正在生成这样的东西:
它是对列表进行排序的 rel 值
Same problem here.
In my case, I noticed that a 12 items list with values 0 to 11 got sorted like 0, 1, 10, 11, 2, 3... As string ordering instead of numerical order, I mean. Maybe there's some way to force asm-select to do the conversion to numbers or to sort by numerical order?
EDIT: nevermind, I was trying to use a "option_1", "option_2", etc, string to order it. If the values it uses to order is not a valid numerical string, it falls back to order as string.
Kchau, could it be you aren't storing the order in an extra field, or using the database id field to detect the order in quitch the options where stored? Once you got the order stored (or detected, what you prefer), it's a matter of generating the rel value for the code to order. I'm generating something like this:
it's the rel value what orders the list
在启动 asm select 之前放置以下内容:
它确保所选项目的放置顺序与您告诉它们的顺序相同。
并确保当您将行保存到数据库中时,它们会保持该顺序,并且当您将行保存到数据库中时,它们会保持该顺序 。在页面加载时收集它们,它们也仍然按相同的顺序排列。
Place the following before you initiate the asm select:
It makes sure that the selected items are put in the same order as you told them to be in.
And make sure that when you save the rows in the database they maintain that order and when you collect them on the page load they are also still in the same order.