Skip to content

Instantly share code, notes, and snippets.

@tmiller
Last active August 29, 2015 14:04
Show Gist options
  • Save tmiller/d608e2ae6f7d0740038d to your computer and use it in GitHub Desktop.
Save tmiller/d608e2ae6f7d0740038d to your computer and use it in GitHub Desktop.
jQuery event sample
$(document).ready(function() {
$(document)
.on(
'ajax:before',
'form.single-line-qualification',
function(e) {
if (e.target[1].value.trim() === '') {
e.target[1].value = '';
alert('You must enter a name!');
return false;
}
}
)
.on(
'ajax:success',
'form.single-line-qualification',
function (data, status, xhr) {
// insert the data returned into the page
$('#articles').append(data);
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment