views:

148

answers:

4

Hello, I have an easy script, that works in all browsers, except IE(8, haven't tryed lower versions yet).

$('.deleteItemIcon').click(function() {
    var deleteConfirm = confirm('Do you really wanna delete that item?')
    if (!deleteConfirm) {
        return false;
    }
});

Can you see a reason, why that shouldn't be working, if yes, how to make it work?

+1  A: 

Possibly the missing semi colon after the confirm?

Why not also just change it to

return confirm('Do you really wanna delete that item?');
Robin Day
The missing semi-colon shouldn't matter because line-breaks are permitted to terminate statements in JavaScript. It is Best Practice™ to use semi-colons though.
Andy E
tryed it and doesnt work for me, there is nothing more going on on the page .. I'm confused, why it doesn't work.
Mike
In that case you need to be more specific about what doesn't work, as others have asked... Can you create a simple test harness that fails for you and paste the entire html?
Robin Day
tested the code Matt posted and it doesn't work either, so .. =/
Mike
A: 

It's working in IE8 for me.. maybe we need to see more code to see what's going wrong.

Here is my working example: http://jsfiddle.net/GdsLF/

Matt
This code doesn't work for me either, so it's problem with my IE I guess.
Mike
A: 
$('.deleteItemIcon').click(function() {
return confirm('Do you really wanna delete that');
});

try it like this

you don't need to put your confirm in a variable and check it after to return false. Confirm already returns true or false so you can simply return the result of your confirm().

meo
A: 

Just curious, to those who this code does not work for... are you using IETester? I had several problems with IE8 (when using IETester) and once I actually took the 20 minutes to upgrade to ie8 I found the code worked... Just a thought. Another note, I went through and made sure I was fully updated with IETester and still had the problems. Confirms and Alerts were not working properly (if at all...) for ie8.

travismillward