Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
// 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
// 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