Skip to content Skip to sidebar Skip to footer

Ie7 Issues With My Jquery [click And Change Functions]

I have the following snippets of code. Basically what I'm trying to do is in the 1st click function I loop through my cached JSON data and display any values that exist for that i

Solution 1:

Fact: change event on radio buttons and checkboxes only get fired when the focus is lost (i.e. when the blur event is about to occur). To achieve the "expected" behaviour, you really want to hook on the click event instead.

You basically want to change

$('input').live('change', function() {
    // Code.
});

to

$('input:radio').live('click', functionName);
$('input:not(:radio)').live('change', functionName);

functionfunctionName() {
    // Code.
}

(I'd however also take checkboxes into account using :checkbox selector for the case that you have any in your form, you'd like to treat them equally as radiobuttons)

Solution 2:

I think this is because IE fires the change when focus is lost on checks and radios. so if the alert is popping up, focus is being lost and therefor the change event is firing.

EDIT:

try changing the $('input') selector to $('input:not(:radio)')

so the click will fire for your radios and the change for all your others.

Edit #2:

How bout putting the stuff that happens on change into a separate function. with the index as a parameter. then you can call that function from the change() and the click(). put the call to that function after your done with the click stuff.

Solution 3:

You're declaring your blnCheck variable inside one of your document.ready() functions. You don't need two of these either, it could all be in one.

This means that the variable that you're declaring there won't be the one used when your change function is actually called, instead you're going to get some kind of implicit global. Don't know if this is part of it, but might be worth looking at. You should declare this at the top of your JS file instead.

Post a Comment for "Ie7 Issues With My Jquery [click And Change Functions]"