Skip to content

Instantly share code, notes, and snippets.

@rmrhz
Created Jan 11, 2016
Embed
What would you like to do?
<div field='field_name'>
<span class='editable' data-field='field_name'>bar</span>
</div>
$(document).on('click', 'span.editable', function () {
var data = $(this).html()
var field = $(this).data('field')
$('div[field="'+field+'"]').html("<input class='form-control quickie' type='text' data-field='"+field+"' value='" + data + "'>")
})
$(document).on('focusout', 'input.quickie', function (event) {
var data = $(event.target).val();
var field = $(event.target).data('field')
$('div[field="'+field+'"]').html("<span class='editable' data-field='"+field+"'>"+data+"</span>")
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment