public
Description: Edit in place plugin for jRails.
Homepage:
Clone URL: git://github.com/rakuto/jrails_in_place_editing.git
100644 42 lines (32 sloc) 1.2 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
JrailsInPlaceEditing
====================
 
Edit in place for jRails.
 
Example
=======
  # 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] # Name of parameter is always '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 comments in jrails_in_place_macros.rb.
 
Dual Licenses
================
This plugin uses implementaion of in-place editor for jQuery, created by Rakuto Furutani
Implementation of in-place editor for jQuery that created by David Hauenstein is used.
Thank you.
 
Copyright (c) 2008 Rakuto Furutani, released under the MIT license