views:

535

answers:

1

I have some code that isn't doing what I want it to in IE8. When you hit the "preview" submit button, a bit of Javascript jumps in and changes the form's action to franchisepreview.php. This sets a session variable so when you go back to the form you won't loose anything. Hitting "Update" or "Insert" goes straight to a query that inserts a franchise.

In IE8 the Javascript isn't jumping in. It submits the form without ever changing the action.

The bit of jQuery I'm using:

The bind:

jQuery("#preview").bind("click", changeForm);

The function changeForm:

function changeForm(event)
{
    alert("Before: "+ jQuery("#franchiseform").attr("action"));
    jQuery("#franchiseform").attr("action", "franchisepreview.php");
    alert("After: "+ jQuery("#franchiseform").attr("action"));
    jQuery("#franchiseform").submit();
}  
A: 

Maybe try chaining to make sure the attribute is set before the form is submitted:

jQuery("#franchiseform").attr("action", "franchisepreview.php").submit();

Doesn't look like .attr() accepts a callback.

carillonator
Chaining is a much more efficient way as well since the DOM is only traversed once P.S - .attr() is not an async type function so a callback is not necessary.
Ariel
Nope, didn't work.
Josh K