user2759575
user2759575

Reputation: 553

Loading partial with link_to

So I have a link_to button that loads with a partial with js.

Here is the link:

<%= link_to "See all...", questions_post_comment_path, class: "button", id: "new_link", :remote => true %>

The partial i'm loading looks like this:

<% @content.each do |content| %>
   <%= link_to "Link", my_path %>
<% end %>

and here is the js:

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

Everything loads fine but now instead of being linked to 'my_path' each link goes to questions_post_comment_path and each link in the partial is affected by the 'button' class. How do i load the partial on a click without affecting the partials contents?

Upvotes: 0

Views: 117

Answers (1)

Anton Grigoryev
Anton Grigoryev

Reputation: 1219

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

Upvotes: 2

Related Questions