Skip to content

Rails gem that makes updating a field from a database via ajax simply by converting a link into a texfield, textarea or a datefield.

Notifications You must be signed in to change notification settings

firebait/simply_edit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!!

About

Rails gem that makes updating a field from a database via ajax simply by converting a link into a texfield, textarea or a datefield.

Resources

Stars

Watchers

Forks

Packages

No packages published