0

I have the following animation :

           $(this).animate({
              marginLeft: '-25%',
              width: "50%",
              minWidth: '400px',
              maxWidth: '700px',
              padding: 0,
              minHeight: "580px",
              height: 'auto',
              borderRadius: 0
            }, 1000, function () {
              alert("I'm not being displayed!!");
              $(this).addClass('completed');
            });

All seems ok, but the callback is not been called in IE7 or 8. Why would this be? I removed the last comma after borderRadius which fixed the original animation problem, but now this is the new issue. Can anyone help?

EDIT:

The final alert with the punctuation error is not actually in the code, I have only placed it there to avoid people pointing out that the addClass part may have been the problem!

Rick Donohoe
  • 7,081
  • 6
  • 26
  • 38

3 Answers3

4

Add an escape in the "I ' m "

  $(this).animate({
                      marginLeft: '-25%',
                      width: "50%",
                      minWidth: '400px',
                      maxWidth: '700px',
                      padding: 0,
                      minHeight: "580px",
                      height: 'auto',
                      borderRadius: 0
                    }, 1000, function () {
                      alert('I\'m not being displayed!!'); // needed an escape
                      $(this).addClass('completed');
                    });
Brandt Solovij
  • 2,124
  • 13
  • 24
1

You can try this too:

$(this).animate({
          marginLeft: '-25%',
          width: "50%",
          minWidth: '400px',
          maxWidth: '700px',
          padding: 0,
          minHeight: "580px",
          height: 'auto',
          borderRadius: 0
        }, 1000).promise().done(function(){
          alert("I'm not being displayed!!"); // <---use double quotes or escape them
          $(this).addClass('completed');
        });
Jai
  • 74,255
  • 12
  • 74
  • 103
1

For anyone interested I found out what the problem was. Apparently IE 7 and 8 had problems dealing with height: 'auto' within the animate function, which was causing it to not fire off the callback.

I decided to use trial and error to comment out certain properties until I found the culprit after reading an answer on this question - jQuery example (in jsfiddle) working in firefox but not in IE8, 7 - by Jeff B

Community
  • 1
  • 1
Rick Donohoe
  • 7,081
  • 6
  • 26
  • 38