circey
circey

Reputation: 2042

jquery function not working in IE7 only

I have the following jquery code:

$(function() {
    $('.sliding-buttons').click(slidingContent);
});

function slidingContent(e) {
    var boxID = $(this).attr('id'),
        boxName = $(this).attr('name');

    $('.sliding-holder#s-h-' + boxName).css({'display' : 'block'}).addClass('open');
    $('.sliding-content#s-c-' + boxName + '-' + boxID).css({'display' : 'block'}).addClass('open');
    $('.sliding-box#s-b-' + boxName).stop(true, true).animate({
        top:'0'
        },'slow');

    e.stopPropagation();
    e.preventDefault();
}

It's working in all browsers except, naturally, IE7. In IE7 it fails to stop the propagation.

I'm using the latest version of jquery (1.6.2) but have also tried 1.5.2.

I'm really at a loss here; there are no trailing commas (that I can see...) and I can't find the problem. I'd really appreciate some assistance!

MTIA.

Upvotes: 1

Views: 642

Answers (2)

Vivek
Vivek

Reputation: 11028

i am just guessing...can you try in this way...

$(function() {
    $('.sliding-buttons').click(function(e){
         var boxID = $(this).attr('id'),
        boxName = $(this).attr('name');

    $('.sliding-holder#s-h-' + boxName).css({'display' : 'block'}).addClass('open');
    $('.sliding-content#s-c-' + boxName + '-' + boxID).css({'display' : 'block'}).addClass('open');
    $('.sliding-box#s-b-' + boxName).stop(true, true).animate({
        top:'0'
        },'slow');

    e.stopPropagation();
    e.preventDefault();

   });
});

or you need to pass event object to called function in this way-

$('.sliding-buttons').click( slidingContent(e) );

Upvotes: 1

Jose Faeti
Jose Faeti

Reputation: 12314

If slidingContent is a function, then you may want to treat it like a function, using parenthesis by calling it. Also, since you are referring to the original event inside the slidingContent function, you may need to pass the event as a function parameter (not sure about this though since I never used events like you are using.

$('.sliding-buttons').click( slidingContent(e) );

Upvotes: 0

Related Questions