Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6032011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:16:14+00:00 2026-05-23T05:16:14+00:00

I have a problem with rendering @results from show.js.erb . Output looks like: show.js.erb

  • 0

I have a problem with rendering @results from show.js.erb. Output looks like:output from show.js.erb template

show.js.erb

$('#results').empty();
$('#results').html("<ul><%= escape_javascript(render(@results)).html_safe %></ul>");

_result.html.erb

<li>
  <%= link_to(result.title, result.uri) %><br>
  <span class="urls"><%= result.uri %></span>
</li>

Using _result.html.erb in show.html.erb:

<ul>
  <%= render @results %>
</ul>

produces correct output.

The suspected culprit is <%= escape_javascript(render(@results)).html_safe %>.
I’ve tried <%= raw(escape_javascript(render@results)) %> but with no luck.
App is created with Rails 3.0.8.

Edit 1:

Longer version of show.js.erb:

$('#results').empty();
$('#results').html("<ul><%= escape_javascript(render(:partial => "results/result",   :collection => @results)).html_safe %></ul>");

output stays the same as on the image with a>, li> and whatnot.

Edit 2:

HTML rendered by show.js.erb:
enter image description here

Edit 3:

<a href="http://jasonseifer.com/2010/04/06/rake-tutorial">Rake Tutorial | Jason Seifera&gt;<br>  <span class="urls">http://jasonseifer.com/2010/04/06/rake-tutorialspan&gt;li&gt;</span></a>

Edit 4:

without html_safe:

$('#results').empty();
$('#results').html('<ul><%= escape_javascript render(@results) %></ul>');

Output:

output without html_safe

The </ are already eaten by escape_javascript.

Edit 5: It is working! Finally!

$('#results').html('<%= escape_javascript("<ul>#{render(@results)}</ul>").html_safe %>');

It is Dogbert’s answer with .html('') quotes and .html_safe.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:16:15+00:00Added an answer on May 23, 2026 at 5:16 am

    Please try using this for your js.erb

    $('#results').html(<%= escape_javascript "<ul>#{render(@results)}</ul>"%>);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with rendering my html page by the same browsers in
Ok so I have a problem with rails and rendering partials. I have a
Ok, here's a problem I'm having. I have Lua bindings to a rendering engine
I have problem with show or hide form in Window Form Application. I start
I have problem with UIWebView delay when the load image from url. In my
I have problem while loading data into html select when users press or click
today I have a (simple) rendering problem for you. My current project gets datas
While I have made a topic like this in the past, this is from
I have a problem. I am calculating position of some points for opengl rendering.
I have problem with http://abfoodpolicy.com/ . In IE 8 and 9 the right sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.