tags:

views:

76

answers:

1

The following JQuery function is not working entirely. IE 7 processes both alerts, but FF 3.0.10 only the first alert is fired. What did I do incorrectly?

function submitClick() {
    var submitButton = '#<%=SubmitButton.ClientID%>';
    alert('got here');

    $(submitButton).click(function() {
        alert('got here too');
        $.blockUI({ message: $('#process-message') });
    });
}

Also, I called alert($(submitButton)); and this does return an "Object object" in FF.

+2  A: 

You don't seem to be doing there what you think you're doing.

What you're actually doing is in the submitClick() method you are adding a click event handler to a button. But you're not calling that handler. That won't happen until you actually click the button.

Are you trying to programmatically click that button? If so, you're not doing that. This will click the button:

function submitClick() {
    var submitButton = '#<%=SubmitButton.ClientID%>';
    alert('got here');

    $(submitButton).click();
    alert('got here too');
    $.blockUI({ message: $('#process-message') });
}
cletus
It looks like I was using two version of the code, one added the event handler on ready, the other I just put the JS function call on the actual button. At some point the two got mushed together. Thanks.
blu