I'm trying to use jeditable with my rails 3 apps. I would like to edit some fields inline. Actually it's working on my client side but the data isn't updated in my app.
Could you take a look? Thanks in advance!
my view:
<dt>Overview :</dt>
<dd class="edit_textfield" id="<%= @project.id %>" name="overview"><%= @project.overview %></dd>
my controller:
def update
project = Project.find(params[:id])
overview = params[:value]
project.save
render :text => params[:value]
end
my application.js:
$(".edit_textfield").each( function() {
$(this).editable('update', {
type : 'textarea',
cancel : 'Cancel',
submit : 'OK',
indicator : 'Saving...',
tooltip : 'Click to edit...',
rows : 10,
method : "put",
submitdata : {id: $(this).attr('id'), name:$(this).attr('name') }
});
});
Thanks to kschaper, it works.
But when I use jeditable for 2 fields in my page and that I edit them, only one is saved. Rails believe that the second value is 0
I think that the problem come from my controller :
def update
@project = Project.find(params[:id])
@project.name = params[:name]
@project.overview = params[:overview]
@project.save
respond_to do |format|
format.js #{ render :text => params[:value] }
end
end
Do you have a clue?
Is overview an attribute of project? Then it should be
@project.overview = params[:value]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With