Mark Kadlec
Mark Kadlec

Reputation: 8440

Why is application.html.erb being called on a js response?

In my Rails app I have a Ajax call to update a property:

def add_properties
    @conversation = Conversation.update(params[:conversationId], :points=> => params[:conversation][:points])

    respond_to do |format|
       format.js { render :partial => "add_properties" }
    end
end

And my _add_properties.js.erb is simple:

$('#ajaxFeedback').html('Property updated').show().fadeOut(4000);

What I am finding is that the call to the partial is choking due to some JQuery UI declarations in my application.html.erb. When I remove the declarations, all works well. How can I simply render the partial without calling the application.html.erb?

Any help would be appreciated!

Upvotes: 0

Views: 112

Answers (2)

Niko Efimov
Niko Efimov

Reputation: 2213

Why not just rename that to add_properties.js.erb

call

respond_to do |format|
  format.js
end

Upvotes: 0

kobaltz
kobaltz

Reputation: 7070

Have you tried?

format.js { render :layout => false, :partial => "add_properties" }

Upvotes: 1

Related Questions