Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery bug? .appendTo() not working in IE7

I am trying to create an option transfer plugin for jQuery.

I have the basic functionality working in opera, firefox, chrome & safari but IE7 is failing to co-operate.

The transfer functions in IE7 appear to operate very sporadically and incomprehensibly.

I have created an example page to illustrate my problem.

Can anyone see where I am going wrong?

Thanks,

like image 746
Mike Avatar asked Feb 04 '10 15:02

Mike


2 Answers

This doesn't look like an .appendTo()-error-in-jQuery as much as an IE7-has-superfunky-select-box-behavior problem. This workaround seems to make it behave:

.parent()
 .click(function () {     
    $selectBox1.find('option:selected')
               .appendTo($selectBox2.find('select'));
    $selectBox1.html($selectBox1.html());
    $selectBox2.html($selectBox2.html());                               
    sortBox($selectBox2); 
   })

Rebuilding the html of each select box after the appendTo() forces IE to update its state.

JSbin: http://jsbin.com/opome3/4 (fixed with .clone(true) for first button.)

like image 112
jkyle Avatar answered Nov 16 '22 11:11

jkyle


I'm getting an error in ie:

Line: 16 Error: 'undefined' is null or not an object

That points to this:

j=l.replace(/^[\-\d\.]+/,"")

I'm guessing you need to test for null? Just a guess.

like image 31
user113716 Avatar answered Nov 16 '22 11:11

user113716