views:

59

answers:

1

The title is the error I get from the following code:

 $(this).parent().slideUp(200, function () {
    $("#testDiv").slideUp(200);
    });

However the following code works fine:

$(this).parent().slideUp(200, function () {
$("#testDiv").html('hello');
});

Loaded libraries are jQuery, jQuery UI and qTip.

In IE8 I get the error as indicated. In FireFox the first slideup works then the callback causes an error and scripts stop.

The script is located in a click function handler on a div that is dynamically rendered (server-side) in an ASP.NET MVC partial view via a jQuery load(). The testDiv div is on the view itself and rendered in the original request.

Any ideas why the html() call works, but not the animation?

+1  A: 

Most likely has something to do with your use of .parent(). I recommend using .parents('.ClassName') and calling it by a specific class name or ID.

This will help clear up most of those issues.

Good luck!

Joshua
I agree. You should never write any code like above. What if parent is empty?
Vladimir Kocjancic
Given the way the parent and child is created it is impossible for the parent to be empty for that block of code. 'Never' is a very strong pattern ;o)The problem isn't the parent or the call to parent or the slideUp on parent. The problem is that the slideup doesn't work on the $("#testDiv") selection.Cheers.
MisterJames