-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
53 lines (30 loc) · 1.68 KB
/
README
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
43
44
45
46
47
48
49
50
51
52
53
Simply edit is a view helper that convert any label into an editable text, textarea or date picker field using JQuery.
Why did I make a gem out of this little thing? I felt it was a waste of time to got to a form if you only needed to update a title, content or a date. The helper currently only supports, text, textarea and date. The date field is basically a jQuery date control so styling in depends on the jQuery UI templating framework.
Anyway, hope you guys like it and sure there is always room for improvement.
Installing:
Add this to you Gemfile:
gem 'simply_edit'
The run:
bundle install
As simply_edit uses a javascript files, you will be required to install it for use (also remember to include it with javascript_include_tag):
rails g simply_edit
First you will need to include jquery-ui to you javascript files if you want to use the date_picker functionality.
Rails 3.1 (add this to application.js):
//= require jquery-ui
<= Rails 3.0:
Add the jquery-ui.js file of your preference to you layout file.
Using:
On any of your views just use this code:
<%= simply_edit_text_field(object, field, update_url, {other options} %>
<%= simply_edit_text_area(object, field, update_url, {other options} %>
<%= simply_edit_date_field(object, field, update_url, {other options} %>
Callbacks:
In order to react to a edit success and error event, you will need to listen to the "simply_edit:success" and "simply_edit:error" events like this:
$("#simply_edit_object").live("simply_edit:success", function(data){
alert("Updated sucessfully.");
}
$("#simply_edit_object").live("simply_edit:error", function(data){
alert("Failed to edit.");
}
That is basically it.
Hope you like it!!