Reputation: 8504
My setup: Rails 3.0.9, Ruby 1.9.2, jQuery 1.6.2
I'm making an AJAX call from jQuery to my Rails app to this controller
class ProjectsController
def data
@project = ....
respond_to do |format|
format.html
end
end
end
For the data
action, I need to render a partial file in the views\projects\_property.html.erb
. What's the syntax for format.html
? I tried a variety of ways but couldn't find the right syntax.
Upvotes: 0
Views: 763
Reputation: 115541
For ajax:
def data
@project = ....
respond_to do |format|
format.html
format.js
end
end
And in data.js.erb
$("#your_id").html("<%= escape_javascript( render :partial => 'property' )%>");
Upvotes: 3