simplemodal click events stopped working in IE7

Posted by prettynerd on Stack Overflow See other posts from Stack Overflow or by prettynerd
Published on 2010-05-28T04:00:50Z Indexed on 2010/05/28 4:51 UTC
Read the original article Hit count: 179

Filed under:

Here's my code:

$('#alertInfo').modal({
    close :false,
    overlayId :'confirmModalOverlay',
    containerId :'confirmModalContainer',
    onShow : function(dialog) {
        dialog.data.find('.message').append(message);

        dialog.data.find('.yes').click(function(){
            if ($.isFunction(callback)) callback.apply();
            $.modal.close();
        });

        dialog.data.find('.close').click(function(){
            $.modal.close();
        });  
    }
});

Basically, this is a dialogue box which I call to show a warning message that has a "X" button (with class 'close') and an "OK" button (with class 'yes').

The problem occurs in IE7. When I call this dialogue box and use my "X" button to close it everytime, my "X" button does not work anymore on the third time I call it (YES ON THE THIRD TIME!). However, if I use my "OK" button to close the dialogue box, it works fine no matter how many times I call it.

I thought I found a workaround by unbinding and binding my click event of the '.close' class, as below:

dialog.data.find('.close').unbind('click');
dialog.data.find('.close').bind('click',function(){$.modal.close();});

and it worked!!! unfortunately, however, the problem now occurs in my "OK" button. so, i did the same unbinding and binding the click event of the '.yes' class, as below:

dialog.data.find('.yes').unbind('click');
dialog.data.find('.yes').bind('click',
    function() {
        if ($.isFunction(callback)) callback.apply();
        $.modal.close();
});

BUT NOPE, IT DOES NOT WORK.. please help me.. @ericmmartin, i hope you're online now.. huhu..

© Stack Overflow or respective owner

Related posts about simplemodal