Created
September 8, 2014 21:38
-
-
Save Ethanhackett/d395ecf19842eeff0813 to your computer and use it in GitHub Desktop.
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() { | |
// Loop through each of the empty .editable elements and add filler edit text. | |
$('.editable:empty').each(function(){ | |
$(this).text('Edit Me'); | |
}); | |
// On .editable blur() - when a user clicks off of an .editable element take it's text and pass it to the corresponding input. | |
$('.editable').blur(function() { | |
var editableContent = $(this).text(); | |
var inputID = '#' + $(this).data('editable-input-id'); | |
// If there isn't any content in the input area replace it with edit text filler text. | |
if (editableContent == '') { | |
var editableContent = ''; | |
$(this).text('Edit Me'); | |
} | |
// Replace the input's value | |
$(inputID).val(editableContent); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment