backbone-forms
backbone-forms copied to clipboard
Fix ensuring order of items in checkboxes and select options
I came across an issue where the options in select elements were ordered inconsistently across browsers.
It looks like jQuery's add()
cannot guarantee the order of elements added, which we can ensure by using a document fragment.
What browser is this an issue with ?
I tested it on Chrome and Firefox. Chrome was displaying select options in a seemingly random order, albeit consistent. Firefox was always displaying the options in the order expected (as specified through comparator
).
The commit has conflicts, Can you just update the src files, the build process will run soon after merge (and prevent the merge conflicts)
Would it not be better to push the items into an array, then return this - html() will take an array of elements (from jQuery 1.8 I believe) https://jsfiddle.net/glenpike/noc4Lxoo/
(It avoids chopping and changing between vanilla & jQuery based script)