rvera / image-picker

Image Picker is a simple jQuery plugin that transforms a select element into a more user friendly graphical interface.
http://rvera.github.com/image-picker
Other
907 stars 216 forks source link

Get selected in the order they were clicked #151

Closed akulsanthosh closed 4 years ago

akulsanthosh commented 4 years ago

$("select").data("picker").selected_values() returns the values in the order they where initialised, can I get the same in the order they were clicked.

Example :

``

On clicking 4 then 1 then 5 $("select").data("picker").selected_values() returns [1,4,5] but is it possible to get [4,1,5]

akulsanthosh commented 4 years ago

`var prev = [] var order = []

function stringcreate(curr){ intersection = curr.filter(x => !prev.includes(x)); if (intersection.length == 1){ order.push(intersection[0]) console.log(order) } else{ removed = order.filter(x => !curr.includes(x)) order = order.filter(x => x !== removed[0])
console.log(removed,order) } }

$("select").imagepicker( { hide_select : true, clicked: function(s,i){ curr = this.val() stringcreate(curr) prev = curr } } )`

A rough solution. I hope someone implements this