选择:保持多重选择顺序 [英] Chosen: Keep Multiple Selection Order

查看:88
本文介绍了选择:保持多重选择顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用选择的多项选择。我希望能够跟踪用户选择的订单。例如,如果用户先选择option2,然后选择option1,则我想按option2和option1的顺序获取结果。但选择排序用户选择的选项。我有办法告诉我选择不对结果进行排序吗?

I am using Chosen's Multiple selection. I want to be able to track user selected order. For example, if a user select option2 first then option1, I want to get the result in the order of option2 and option1. But chosen sorts user selected options. Is there a way I can tell chosen to not sorting the result?

推荐答案

我写了一个简单的插件与Chosen一起使用。它允许您检索选择的多个选择元素的选择顺序,还可以从有序值数组中进行设置

I wrote a simple plugin to use along with Chosen. It allows you to retrieve the selection order of a Chosen multiple select element, and also to set it from an array of ordered values.

它在Github上可用: https://github.com/tristanjahier/chosen-order

It is available on Github : https://github.com/tristanjahier/chosen-order

它与Chosen 1.0+以及jQuery和Prototype版本兼容。每个框架都有一个插件,可让您执行以下操作:

It is compatible with Chosen 1.0+ and with both jQuery and Prototype versions. There is also a plugin for each framework, which let you do things like this:

var selection = $('#my-list').getSelectionOrder();



按顺序设置所选值



Set the selected values in order

var order = ['nioup', 'plop', 'fianle']; // Ordered options values
$('#my-list').setSelectionOrder(order);

签出。

这篇关于选择:保持多重选择顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆