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

  • Home
  • SEARCH
  • 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 4074868
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:13:33+00:00 2026-05-20T17:13:33+00:00

The app in question utilizes jQuery to do ajax requests in order to populate

  • 0

The app in question utilizes jQuery to do ajax requests in order to populate dependent select boxes. My controller action responds_to :js, and in the .js.erb file I have:

str += '<%= f.select field.name, list, {}, { :class => "list", :multiple => "multiple", :style => "size:8; width:100px;" } %>';

“list” is populated like so:

str += '<% list = @validation_model.lookup([field], @lookup) %>';

I am .append()’ing this to a div. at the end of the .js.erb template file. However, when “list” contains more than one value, the parsing of the template fails. If it is empty, or contains only one value, parsing is successful.

Is this a bug I am running into, or am I doing something wrong? Please note this is appearing as a parse error rather than a runtime error, so I have been unable to determine exactly what the problem is in either Firebug or Safari Dev.

UPDATE: Here is the full code of the .js.erb file. I have replaced the “list” variable with inline logic to retrieve an array.

str = '<% fields_for :mapapps do |f| %>';
<% for tf in @tag.tag_fields.find(:all, :order => :sequence) %>
    <% field = tf.parentfield %>
    <% if !@lookup.include?(field) %>
        $("#<%= field.name %>").remove();
    <% else %>
        <% next %>
    <% end %>
    str += '<div id="<%= field.name %>" class="floater">';
    str += '<label for="mapapps_<%= field.name %>"><%= field.label %></label>';
    str += '<%= f.select field.name, @validation_model.lookup([field], @lookup), {}, { :class => "list", :multiple => "multiple", :style => "size:8; width:100px;" } %>';
    str += '</div>';
<% end %>
str += '<% end %>'
$("#mfrsdiv").append(str);
  • 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-20T17:13:34+00:00Added an answer on May 20, 2026 at 5:13 pm

    I got the code working. All I needed to do was to put “escape_javascript” around the call to f.select.

    str += '<%= escape_javascript(f.select field.name, @validation_model.lookup([field], @lookup), {}, { :class => "list", :multiple => "multiple", :style => "size:8; width:100px;" }) %>';
    

    It should be noted that the code in my question above will still fail for the reasons mentioned rubyprince, but the rendering issue itself is solved by the escape_javascript.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is about App domains and Sessions. Is it possible to have IIS
the question I am having is: when running my app with a launch code
My question pertains to multi-threading in Java. I'm translating an app I wrote in
I'm writing an app in C# (.net 3.5) and I have a question about
This is related to this question . I'm writing a Flex app (a WindowedApplication)
Sorry for the slightly noobish question, as I am writing my first rails app.
Okay this is a fairly broad question. This is my first App and I'm
This may be a very noobie question, but in today's world of web app
This may seem like a dumb question, but can an app build with c#
This would be a question for anyone who has code in the App_Code folder

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.