Error in selection after sorting dropdown list
I have sorted a dropdown list with this function:function SortOptions(id) {
var prePrepend = "#";
if (id.match("^#") == "#") prePrepend = "";
$(prePrepend + id).html($(prePrepend + id + " option").sort(
function (a, b) { return a.text == b.text ? 0 : a.text < b.text ? -1 : 1 })
); }
But when i'm selecting a object i get the item with the index from before sorting.
The selection is happening with this function:
var selectedType = typeDropdown.selectedItemData();
selectedItemData: function (index) {
var settings = this.data(extensionName);
if (typeof (index) === 'undefined') {
return settings._items ? settings._items[this[0].selectedIndex] || null : null;
} else {
this[0].selectedIndex = index;
this.selectmenu('refresh');
}
}
Is this enough information?
Thanks in advance