Reputation: 121
I have looked at similar question and the answers didn't work and may be dated. I think there used to be a thing called RJS to do this but, I am trying to simply remove one partial and replace another.
$("#me")
.replaceWith( '<%= escape_javascript render(partial: "photoSpread") %>')
What happens is the its sent to the browser as text and just displays <%= escape_javascript render(partial: "photoSpread") %>
Upvotes: 0
Views: 229
Reputation: 121
sorry I wasn't thinking. rails is servver side so I have to load all the partials first and then swap. Something like this.
jQuery ->
$("#me2").hide()
$("#go").on "click", ->
$("#me").toggle()
$("#me2").toggle()
Upvotes: 0
Reputation: 23671
Replace <%
with <%=
$("#me").replaceWith('<%= escape_javascript render("photoSpread") %>')
<%
will just evaluate the ruby code inside itwhereas
<%=
will evaluate and print the code inside <%= %>
Upvotes: 2