Skip to content

Instantly share code, notes, and snippets.

@chadoh
Created June 15, 2011 11:09
Show Gist options
  • Save chadoh/1026891 to your computer and use it in GitHub Desktop.
Save chadoh/1026891 to your computer and use it in GitHub Desktop.
$("*[contenteditable]").live({
blur: function(){
var model = $(this).attr("data-model"),
attribute = $(this).attr("data-attribute") || $(this).attr("class"),
value = $(this).text(),
path = $(this).attr("data-path"),
updateData = {};
updateData[model] = {};
updateData[model][attribute] = value;
$.ajax({
type: 'PUT',
dataType: 'script',
url: path,
data: updateData
});
},
keypress: function(e){
if (e.keyCode == 13)
$(this).blur();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment