Bug: sorting of number items in natural order
-
Hi,
I recently found a bug in your plugin, I have a multiselect which starts with numbers. They are ordered in natural order. e.g.:
1
11
120
2
25
270
3
33This is unexpected behavior I think.
Because I only use the choosen multi select types, I altered one function:
function woof_init_mselects() { try { jQuery("select.woof_mselect").each(function(select){ var select = jQuery(this); var options = select.find('option'); options.sort(function(a,b) { if ( !isNaN(parseInt(a.text[0])) ) { a = a.text.replace(/[^[0-9]!?]/g,''); b = b.text.replace(/[^[0-9]!?]/g,''); if (parseInt(a) > parseInt(b)) return 1; else if (parseInt(a) < parseInt(b)) return -1; else return 0 } if (a.text > b.text) return 1; else if (a.text < b.text) return -1; else return 0 }); select.empty().append(options); }); // jQuery("select.woof_select").chosen('destroy').trigger("liszt:updated"); jQuery("select.woof_mselect").chosen(/*{disable_search_threshold: 10}*/); } catch (e) { }
Can you please fix it for all list types in your code?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Bug: sorting of number items in natural order’ is closed to new replies.