Skip to content

@nakajima /form-handler.js secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
// A simple event handler for submitting a form via AJAX,
// then closing its containing window.
function submitForm(element) {
// This is a Prototype method for submitting a form
$(element).request({
// This is a callback that will be invoked once the
// request finishes. It just closes the window.
onComplete: function() { window.close(); }
});
// Prevent the form from actually submitting and reloading
// the page:
return false;
}
// Wait until the page has loaded...
$(document).observe('dom:loaded', function() {
// ...then unobtrusively assign the event handler. This
// this prevents the need for the "onclick" attribute in
// your HTML markup.
$('contact').observe('submit', submitForm);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.