blu
blu

Reputation: 13175

Why does this JQuery function not work in FF?

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.

Upvotes: 0

Views: 184

Answers (1)

cletus
cletus

Reputation: 625147

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') });
}

Upvotes: 2

Related Questions