Last active
August 29, 2015 14:04
-
-
Save leesmith/5ce2ddb86051699f79ca to your computer and use it in GitHub Desktop.
jQuery event delegation
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 -> | |
$(document) | |
.on('ajax:before', ".single-line-qualification", (e) -> | |
debugger | |
# do validation and return false to cancel ajax | |
if e.target[1].value.trim() == '' | |
e.target[1].value = '' | |
alert 'You must enter a name!' | |
return false | |
) | |
.on("ajax:success", ".single-line-qualification", (e, data, status, xhr) -> | |
$('#qualifications').append xhr.responseText | |
e.target.remove() | |
# append success message | |
) | |
.on("ajax:error", ".single-line-qualification", (e, xhr, status, error) -> | |
# append error message | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment