l'essentiel est invisible pour les yeux

Saturday, May 03, 2008

[rails] released jrails_in_place_editing

The jrails_in_place_editing is implementation of inplace editor with jQuery, so this plugin is dependent on jRails. This uses David Hauenstein's jQuery inplace editor plugin. Thank you.

INSTALL (Note: Edge Rails)


./script/plugin install git://github.com/rakuto/jrails_in_place_editing.git

USAGE

# Controller
class BlogController < ApplicationController
in_place_edit_for :post, :title
end

# Customize the action that update the value
class BlogController < ApplicationController
# set_#{object}_#{title}
def set_post_title
post = Post.find(params[:id])
post.title = params[:value]
post.save

# It should render a text
render :text => post.title
end
end

# View
<%= in_place_editor_field :post, :title %>

# Pass some options
<%= in_place_editor_field :post, :title, {}, {:field_type => 'textarea', :textarea_cols => 25, :textarea_rows => 10}%>
<%= in_place_editor_field :post, :title, {}, {:field_type => 'textarea', :textarea_rows => 10}%>

For more details, see jrails_inplace_editing/javascripts/jquery.inplace.js