Reputation: 49
I'm about to pull my hair out, because of all the extra time spend on nursing IE -_-
Well, I have an unordered list of divs, which I'm trying to sort. This works perfectly in both Chrome and Firefox, but not IE.
The JS is fairly simple:
$('#VariantContainer > .ProductVariant').sort(function(a,b){
return a.id > b.id
}).appendTo('#VariantContainer')
Check out this fiddle in IE: http://jsfiddle.net/PAJ3w/
Anyone got a clue why?
Thanks :)
BR Martin
Upvotes: 1
Views: 2139
Reputation: 30463
Use number instead of boolean. For me this is the best variant (because it is obvious that we use numbers):
parseInt(a.id) - parseInt(b.id)
Upvotes: 4
Reputation: 702
jQuery(document).ready(function($){
//Order variants
$('#VariantContainer > .ProductVariant').sort(function(a,b){
return a.id - b.id;
}).appendTo('#VariantContainer');
});
Boolean isn't the correct return type and doesn't account for equal values.
Upvotes: 1
Reputation: 385
I think you're missing the semicolon on the line:
return a.id > b.id
Firefox and chrome can ignore those little things, but IE can't. It should be
return a.id > b.id;
You are declaring a function, therefore it follows all regular rules.
Upvotes: -2