Apologies for the bad wording of the question but its pretty straight forward.
I'm sending some paramaters across to the rails application as such
$(document).ready(function() {
console.log("testing!@£");
$('.editable-td').editable(home_address, {
data : " {'E':'Letter E','F':'Letter F','G':'Letter G', 'selected':'F'}",
type : 'textarea',
cancel : 'Cancel',
submit : 'OK',
tooltip : 'Click to edit...'
});
});
When the rails app receives the params, I'd like to respond back with the text that was passed in. Otherwise after you submit the data to the rails server, th开发者_JS百科e textarea you updated will revert to its previous state.
def update puts params @response = (params[:value]) puts "NOWWHATSHOULDIDO"
respond_to do |format|
if params
format.json { head :ok }
# respond with the variable @response here
else
format.json { render :json => @user.errors, :status => :unprocessable_entity }
end
end
end
a small attempt:
def update
puts params
puts "NOWWHATSHOULDIDO"
respond_to :json
if params
respond_with(params) do |format|
format.json { render }
end
end
end
Another small attempt is here which responds to the user but the jeditable area shows up as null. Any ideas?
def update
puts params
@x = (params[:values])
render :json => @x.to_json
end
For the first you could, I believe you could do:
render :text => params[:value], :status => :ok
精彩评论