When using respond_to
, my AJAX call only invokes the javascript response if the HTML response isn't present.
I have the following javascript for submitting an edit-in-place action:
$(".eip").editable("/surveys", {
name : 'survey[name]',
select : true,
event : 'edit',
submit : 'Save',
cancel : 'cancel',
cssclass : "editable",
onblur : 'ignore',
onedit : function() { $(".eip_desc").hide(); },
onreset : function() { $(".eip_desc").show(); },
onsubmit : function() { $(".eip_desc").show(); }
});
Then I have the following Survey controller method:
class SurveysController < ApplicationController
def create
@survey = Survey.new(params[:survey])
if @survey.save
respond_to do |format|
format.html { redirect_to surveys_path, :notice => "Survey created!" }
format.js
end
else
render :action => :new
end
end
end
If I remove the format.html
line, then format.js
responds as it should. But if I leave format.html
in there, then the whole page renders when I submit via that editable
javascript bit.
I'm running Rails 3.0.3 for this app.
from docs
try to pass a method: "put"