keepOrder does not keep order on underlying SELECT: FIX in the post
the order on the underlying SELECT is not kept.
changing this if in the 'select' part solves the problem
if (that.options.keepOrder){
var selectionLiLast = that.$selectionUl.find('.ms-selected');
if((selectionLiLast.length > 1) && (selectionLiLast.last().get(0) != selections.get(0))) {
// added the if MZI: it's needed for the init where multiple values might be selected already in correct order
if( 1 == options.length ){
selections.insertAfter(selectionLiLast.last());
} }
// added by MZI: reorders the underlying SELECT
var ol = ms[0].options[(ms[0].options.length)-1];
options.insertAfter(ol);
}
I think your code has a little problem. I have changed your code to following code, and it worked well.
if (method !== 'init'){ var ol = ms[0].options[(ms[0].options.length)-1]; options.insertAfter(ol); }
If there is any problem, let me know. Thanks
I have a similar problem and I resolved it using an stackoverflow answer but can´t find the question, here is my code:
afterSelect: function(value)
{
$('#select option[value="'+value+'"]').remove();
$('#select').append($("<option></option>").attr("value",value).attr('selected', 'selected'));
var options= $('#select').val().toString();
// DO SOMETHING WITH THE OPTIONS
},
afterDeselect: function(value)
{
$('#select option[value="'+value+'"]').removeAttr('selected');
var options= $('#select ').val().toString();
// DO SOMETHING WITH THE OPTIONS
}
In my particular case I just needed to send a string with the options ordered by the user, but I guess you can send also an array. Good luck & happy coding!
var ol = ms[0].options[(ms[0].options.length)-1]; options.insertAfter(ol);
It solves the issue. but limit selection not working