views:

143

answers:

2

Sigh

I keep getting strange problems with IE 8.

I have this

    <input name="Btn_Edit" disabled="disabled" id="Btn_Edit" type="button" value="Edit"/>

$(function ()
{
    $('#Btn_Edit').live('click', function ()
    {

        alert('hi');

    });
});

So in every other browser this alert would never get trigger as my button is disabled. In IE 8 it goes into my edit button and triggers the alert.

I don't know why.

http://jsfiddle.net/QgceL/

You can see for yourself it. Just load up IE 8 and try it.

However if I change it to this.

http://jsfiddle.net/YD2eS/

It seems to work. I still dont' know why it brings up a different cursor instead of a pointer.

Anyways the problem seems to be with live click event.

A: 

Change live to click. Yes, it's too weird! I don't know why this happens.

Topera
That's now an option. I have 4 ajax tabs. If a user would go to the next tab and come back the button would not work. For now I guess I have to do a check to see if it is actually disabled or not in the actual click event till someone figure out why this happens.
chobo2
You can run event binders each time user clicks in tab, in ajax callback.
Topera
event binders? I am not following
chobo2
$("#myId").click(myFunction): i have bind the function myFunction to event click on a element with id 'mID'. You can call $("#myId").click(....) after each ajax response.
Topera
A: 

change your selector to:

$('#Btn_Edit[disabled!=true]')

Note that this will NOT work if your selector is $('#Btn_Edit[disabled!=disabled]')

which you can see if you do alert($('#Btn_Edit').attr('disabled')); it will be 'false' when it is not disabled and true when it is disabled.

here is a fiddle page to see it in action: http://jsfiddle.net/QgceL/3/

Mark Schultheiss
ya I sort of did something like that. I instead did if($('#Btn_Edit').attr('disabled') == false) // continue in the actual click event. I am not sure your way is faster though. I also find that confusing I never know if to set .attr('disabled',true) or .attr('disabled','disabled').
chobo2