Created
January 10, 2012 19:26
-
-
Save seanbehan/1590651 to your computer and use it in GitHub Desktop.
How To Content Editable
This file contains hidden or 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
<script> | |
// coffeescript | |
$ -> | |
$("#project_fields .project").live "blur", (event)-> | |
// alert($(this).text()) | |
$field = $(this) | |
$project_id = $(this).data("project-id") | |
$data = $(this).text() | |
$attribute = $(this).data("attribute_name") | |
$.ajax | |
url: "/projects/#{$project_id}" | |
data: "#{attribute}=#{$data}" | |
method: "POST" | |
success: (resp)-> | |
$field.highlight() | |
</script> | |
<div id="project_fields"> | |
<div class="project" contenteditable=true data-attribute_name="project[name_of_field]" data-project-id="<%= @project.id %>">Hello World...</div> | |
... more divs | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment