Last active
August 29, 2015 14:04
-
-
Save tmiller/d608e2ae6f7d0740038d to your computer and use it in GitHub Desktop.
jQuery event sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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