Kimpoy
Kimpoy

Reputation: 1974

JavaScript / Jquery click event on IE8 is not working properly

I'm a newbie in web development.

I'm having some issues on the buttons of my project. This line of code is working in all web browsers, except for IE8:

$("#SampleBtn").live("click", function(){
     console.log('It works!');
});

It doesn't respond the way it should be when clicked. In the example, it's supposed to print "It works!", apparently nothing happens. However, if the user clicks on the button without letting go (keydown) for more than 1 second, it works.

I'm not really sure if where the problem is coming from. Does it have something to do with the .live or the click event?

Any help would be much appreciated. Thanks!

Upvotes: 0

Views: 5209

Answers (2)

Kimpoy
Kimpoy

Reputation: 1974

We've found out that locally, there's no problem with the buttons, however, when the app is run in our node.js server, that's where the issue occurs. This was causing the bug on IE8:

filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='image.png',sizingMethod='scale');

It seemed that the preloader is causing the delays on the customized button image's response. Perhaps, it takes time before the images are being fetched. Anyways, we were able to fix this issue by changing to:

 background-image: url('images.png');

But thank you all for taking time sharing your ideas on this. :)

Upvotes: 0

George Mauer
George Mauer

Reputation: 122082

IE8 has quite a few issues but this should definitely work. My best guess is the console.log call is failing (for the reason I mentioned in the comments).

Try changing console.log to an alert and see if it works.

Also try using the delgated version of on

$(document).on('click', '#SampleBtn', function(){
     console.log('It works!');
});

Upvotes: 1

Related Questions