I subscribe to the click event on all submit buttons on my page once loaded. All buttons fire off the correct event when clicked, but this only works once. If you click any two buttons in a row the second button submits the form normally as opposed to running the script. What am I doing wrong?.
Note: I load the form data from "myurl" using .load()
then hook up to the submit buttons' click events in the complete event.
$(document).ready(function()
{
//Load user content
$("#passcontent").load("myurl", function()
{
//subscribe to click events for buttons to post the data back
$('input[type=submit]').click(function()
{
return submitClick($(this));
});
});
});
function submitClick(submitButton)
{
submitButton.attr("disabled", true);
alert(submitButton.closest("form").serialize());
$.post("myurl",
submitButton.closest("form").serialize(),
function(data)
{
alert("woop");
$("#passcontent").html(data);
});
//Prevent normal form submission process from continuing
return false;
}