Christopher Bales
Christopher Bales

Reputation: 1071

Script runs perfectly in all other browsers but IE

This block of code works perfectly fine in all other browsers. It DOES work in IE when I do a hard refresh of the page, but NOT when going to the page again thereafter. I have no idea why. Any incite would be greatly helpful.

function pageLoad(sender, args) {

/// func auto-sets the yellow and red values for mean and median respectfully
function calculateGoals(goal, yellow, red) {

    $(document.body).on('input', goal, function () {

        var g = $(goal), y = $(yellow), r = $(red); //set up the selectors

        y.val(parseFloat(g.val()) + 0.001);
        r.val(parseFloat(g.val()) + parseFloat(g.val()) * 0.2);
        y.attr('value', parseFloat(g.val()) + 0.0001);
        r.attr('value', parseFloat(g.val()) + parseFloat(g.val()) * 0.2);

    });
}

/// call the funcs for mean and median
calculateGoals('.mean-goal', '.mean-yellow', '.mean-red');
calculateGoals('.median-goal', '.median-yellow', '.median-red');
}

The script takes the input from '.mean-goal' and changes the other values accordingly on user input.

JS Fiddle: http://jsfiddle.net/Jn52h/ - It seems to work perfectly fine, even in IE. But on my dev environment, it doesn't work after you reload the page (after a soft refresh).

Upvotes: 0

Views: 103

Answers (1)

Christopher Bales
Christopher Bales

Reputation: 1071

Figured it out. In case anyone runs into this problem, simply change the 'input' func type to 'keyup' for this kind of problem:

$(document.body).on('keyup', goal, function () {

IE sucks.

Upvotes: 1

Related Questions