views:

10261

answers:

9

Hi,

I'm getting crazy with this IE 7...

==> hhttp://neu.emergent-innovation.com/

Why does following function not work in IE 7, but perfectly with Firefox? Is there a bug in the animate-function?

function accordion_starting_page(){
    // hide all elements except the first one
    $('#FCE-Inhalt02-ContentWrapper .FCE-Fade:not(:first)').css("height", "0").hide();
    $('#FCE-Inhalt02-ContentWrapper .FCE-Fade:first').addClass("isVisible");

    $('div.FCE-Title').click(function(){

        // if user clicks on an already opened element => do nothing
        if (parseFloat($(this).next('.FCE-Fade').css("height")) > 0) {
         return false;
        }

        var toHide = $(this).siblings('.FCE-Fade.isVisible');

        toHide.removeClass("isVisible");

        // close all opened siblings
        toHide.animate({"height": "0", "display": "none"}, 1000);

        $(this).next('.FCE-Fade').addClass("isVisible").animate({"height" : "200"}, 1000);

     return false;
    });
}

Thank you very much for your help...

A: 

I'm not sure what the problem is exactly... perhaps you can't animate to "display: none" ? Try this:

toHide.animate({ height : 0 }, 1000, function() { $(this).hide(); });

...thought, it looks like there might be some other issues with the container not having overflow: hidden set on it.

The best way might be to avoid re-inventing the wheel: the jQuery UI plugin has an accordion built-in. http://docs.jquery.com/UI/Accordion I'm sure the honourable Mr Resig & Co have already dealt with whatever bugs you might be encountering.

nickf
A: 

You could make use of the jQuery selector :visible rather than toggling the isVisible class.

Also your animation seems functionally the same as slideUp(1000).

Simon
A: 

Thank you very much, those were great hints! Unfortunately, it still doesn't work...

The problem is that IE shows the content of both containers until the animation is over... Firefox behaves correctly... I thought it's the thing with "overflow: hidden" - but that didn't change anything.

I already tried the accordion-plugin, but it behaves exactly the same...

swalkner
A: 

I had a problem recently where animate() wasn't working as expected and it was down to IE rendering my css padding: properties differently to FireFox.

This seemed to have happened to other people, and I had to hack around in my css; using margins and fixed widths and other such horrible IE hacks, instead.

adam
+3  A: 

I came across a similar problem with the animate function and was surprised when it was showing the error coming from the core jQuery library. However jQuery is fine, its IE you need to cater for.

When animating any attribute of an element in IE, you need to make sure that in your CSS there is a starting point for the attribute you are going to alter. This also applies to Safari.

As an example, moving a div continually to the left,

JQuery:

var re = /px/;

var currentLeft = $("#mydiv").css('left').replace(re,'') - 0;

$("#mydiv").css('left',(currentLeft-20)+'px');

CSS:

mydiv { position: absolute; top: 0; left: 0; }

If you DO NOT put in a left & top starting position IE will eventually throw an error.

hope this helps

Paul

A: 

i found that if you output this value on ie:

(currentLeft-20)+'px'

returns NaNpx, so, the problem is there, i have same issue here!!! agrrrr

rob
A: 

I am facing the same problem with IE, and paul comment help me a lot for resolve the issue.

admin
A: 

As stated by Paul, when using the method. Animate () jQuery IE7 browser does not recognize internally the property 'position'. eg

CSS rule:

li p (bottom:-178px; color: white; background-color: # 4d4d4d; height: 100%; padding: 30px 10px 0 10px;)

Implementation of animation in jQuery:

$('li').hover(function(){

              $this = $(this);

              var bottom = '-45px'; //valor default para subir.

              if( $this.css('height') == '320px' ){bottom = '-115px';}

              $this.css('cursor', 'pointer').find('p').stop().find('.first').hide().end().animate({bottom: bottom}, {queue:false, duration:300});

      }, function(){

         var $this = $(this);

         var bottom = '-178px'; //valor default para descer

            if( $this.css('height') == '320px' ){bottom = '-432px';}

         $this.find('p').stop().animate({***position: 'absolute'***, bottom:bottom}, {queue:false, duration:300}).find('.first').show();

      });//fim do hover()

What to work in all browsers:

CSS rule:

li p (position: absolute; left: 0; bottom:-178px; color: white; background-color: # 4d4d4d; height: 100%; padding: 30px 10px 0 10px;)

JQuery code:

   $('li').hover(function(){

                 $this = $(this);

         var bottom = '-45px'; //valor default para subir.

              if( $this.css('height') == '320px' ){bottom = '-115px';}

              $this.css('cursor', 'pointer').find('p').stop().find('.first').hide().end().animate({bottom: bottom}, {queue:false, duration:300});

      }, function(){

         var $this = $(this);

         var bottom = '-178px'; //valor default para descer

            if( $this.css('height') == '320px' ){bottom = '-432px';}

         $this.find('p').stop().animate({bottom:bottom}, {queue:false, duration:300}).find('.first').show();

      });//fim do hover()

No meu caso a solução se resolveu assim.

Tadeu Luis
A: 

Change your duration for IE. Make it 1/10th what you would in FF, and it should be close to the same behavior in both browsers:

FF

$("#map").animate({"top": (pageY - 101) + "px"},{"easing" : "linear", "duration" : 200});

IE

$("#map").animate({"top": (pageY - 101) + "px"},{"easing" : "linear", "duration" : 20});

Should fix it.

John K