Note that there are some explanatory texts on larger screens.

plurals
  1. PORails 2.3.8 - select box causing parse error when box contains more than one option
    primarykey
    data
    text
    <p>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:</p> <pre><code>str += '&lt;%= f.select field.name, list, {}, { :class =&gt; "list", :multiple =&gt; "multiple", :style =&gt; "size:8; width:100px;" } %&gt;'; </code></pre> <p>"list" is populated like so:</p> <pre><code>str += '&lt;% list = @validation_model.lookup([field], @lookup) %&gt;'; </code></pre> <p>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.</p> <p>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.</p> <p>UPDATE: Here is the full code of the .js.erb file. I have replaced the "list" variable with inline logic to retrieve an array.</p> <pre><code>str = '&lt;% fields_for :mapapps do |f| %&gt;'; &lt;% for tf in @tag.tag_fields.find(:all, :order =&gt; :sequence) %&gt; &lt;% field = tf.parentfield %&gt; &lt;% if !@lookup.include?(field) %&gt; $("#&lt;%= field.name %&gt;").remove(); &lt;% else %&gt; &lt;% next %&gt; &lt;% end %&gt; str += '&lt;div id="&lt;%= field.name %&gt;" class="floater"&gt;'; str += '&lt;label for="mapapps_&lt;%= field.name %&gt;"&gt;&lt;%= field.label %&gt;&lt;/label&gt;'; str += '&lt;%= f.select field.name, @validation_model.lookup([field], @lookup), {}, { :class =&gt; "list", :multiple =&gt; "multiple", :style =&gt; "size:8; width:100px;" } %&gt;'; str += '&lt;/div&gt;'; &lt;% end %&gt; str += '&lt;% end %&gt;' $("#mfrsdiv").append(str); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload