user2759575
user2759575

Reputation: 553

Loading partial on click

I'm trying to load a partial (_unansweredquestions.html.erb) on a click. No error is showing but when clicked nothing happens.

Here is the link (its the correct path):

<%= link_to "Load", unansweredquestions_post_comment_path, id: "new_link", :remote => true %>

here is unansweredquestions.js.erb:

$('#new_link').html("<%= render :partial => 'unansweredquestions' %>");

and here are the routes:

resources :comments do
 member do 
  get :unansweredquestions
 end
end 

What am i doing wrong?

Upvotes: 0

Views: 105

Answers (1)

Addicted
Addicted

Reputation: 749

$('#new_link').html("<%= escape_javascript(render :partial => 'unansweredquestions') %>");

or in Rails 4, you can do in this way

$('#new_link').html("<%= j (render :partial => 'unansweredquestions') %>"); 

Upvotes: 1

Related Questions