1

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

2

3 Answers 3

4

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)
Sign up to request clarification or add additional context in comments.

Comments

1
  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.

Comments

-2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.