views:

446

answers:

3

I've the following css classes

.switch-format{
  background-color: yellow;
}
.switch-format1{
  background-color: blue;
}
.switch-format2{
  color: red;
}

Using this classes I want to do some animation on the following div

<div id="switch-class" class='switch-format' style="margin-top: 5px;">
  Effects - Switch
</div>

Following is my jQuery code which will use switchClass to switch the classes at 5 sec interval

setTimeout(function() {
  alert('Switch 1');
  jq('#switch-class').switchClass('switch-format', 'switch-format1', 3000);
}, 5000);

setTimeout(function() {
  alert('Switch 2');
  jq('#switch-class').switchClass('switch-format1', 'switch-format2', 3000)
}, 10000);

setTimeout(function() {
  alert('Switch 3');
  jq('#switch-class').switchClass('switch-format2', 'switch-format', 3000)
}, 15000);

The first switch happens fine but when the second switch happens it fails in IE8, it works fine in FF3.

The error is 'Invalid Property Value'.

In IE it fails in the following line

fx.elem.style[ fx.prop ] = fx.now + fx.unit;

with the following values

fx.prop = 'borderColor';
fx.now = NaN;
fx.unit = 'px';
fx.elem.style[ fx.prop ] = '';
fx.elem is the div with id 'switch-class';

Code To Recreate this issue

<html>
<head>
    <script type="text/javascript" src ="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"&gt;&lt;/script&gt;
    <script type="text/javascript" src ="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"&gt;&lt;/script&gt;
</head>
<body>
    <style type="text/css">
        .switch-format{
            background-color: yellow;
        }
        .switch-format1{
            background-color: blue;
        }
        .switch-format2{
            color: red;
        }
    </style>

    <div id="switch-class" class='switch-format' style="margin-top: 5px;">Effects - Switch</div>

    <script type="text/javascript">
        setTimeout(function() {
                    alert('Switch 1');
                    $('#switch-class').switchClass('switch-format', 'switch-format1', 3000);
                }, 5000);

        setTimeout(function() {
                    alert('Switch 2');
                    $('#switch-class').switchClass('switch-format', 'switch-format2', 3000)
                }, 10000);

        setTimeout(function() {
                    alert('Switch 3');
                    $('#switch-class').switchClass('switch-format2', 'switch-format', 3000)
            }, 15000);
    </script>    
</body>
</html>

I've tested this in IE8.

Can anyone help me to solve this problem

+2  A: 

You may have an invalid border-color value being set that is influencing these elements. You could try to hunt it down (if it exists), or explicitly set a new value for these classes:

border-color:transparent;

Could be added to your classes to possibly remove this error.

Jonathan Sampson
I've checked for the border-color property, it is not set for the selected div
Arun P Johny
What I've found is when jquery is trying to find out the difference in old and new styles somehow it is detecting a change in the border-color.
Arun P Johny
+2  A: 

It is because if there is a color property set then IE/FF will take the same value for border-color and scrollbar-base-color properties even if there is no border or scrollbar-base- set.

We can fix this issue by setting explicit values for these properties in the switching classes. Fixed classes are given below

    <style type="text/css">
        .switch-format{
            background-color: yellow;
   border: transparent;
   scrollbar-base-color: white;
        }
        .switch-format1{
            background-color: blue;
   border: transparent;
   scrollbar-base-color: white;
        }
        .switch-format2{
            color: orange;
   border: transparent;
   scrollbar-base-color: white;
        }
    </style>

Somehow the value transparent for scrollbar-base-color is not working

Arun P Johny
make sure you tick your own answer to close it.
Dorjan
I try to tick it, but it says 'You can accept your own answer tomorrow.'. So I'll tick it tomorrow.
Arun P Johny
+3  A: 

Hi all,

I had posted this issue in jQuery forum and they have fixed this issue.

Arun P Johny