Topic: JavaScriptGenerator outputting double-escaped javascript

Hi, I'm experiencing an odd issue using page.replace/page.replace_html.

I have a list of links that use link_to_remote to call an action which in turn calls page.replace , which replaces a <DIV> in the page with the contents of a partial. However, instead of replacing the DIV with the html-rendered version of the partial, it replaces it with what seems to be double-escaped javascript output. So in the browser, the DIV is updated to look like this:


try { Element.update("tbl-items-9", "\n
\n
Burgers
\n
\n \n\n
\n\t
\n\t\t
Burgers
\n\t\t

sdfsdf
"); } catch (e) { alert('RJS error:\n\n' + e.toString()); alert('Element.update(\"tbl-items-9\", \"\\n
\\n
Burgers
\\n
\\n \\n\\n
\\n\\t
\\n\\t\\t
Burgers
\\n\\t\\t

content here
\\n\\t
\\n\\t
\\n $34.00 \\n \\n \\n
\\n
\");'); throw e }


The <DIV> is named dynamically, so the 9 in "tbl-items-9" is created from an ActiveRecord object's ID. The controller call looks like this:

  def show_section
    section = MenuSection.find(params[:id])

    render (:update) do |page|
      page.replace_html "tbl-items-#{section.menu.id}", :partial => "/menus/item_list", :locals => {
          :section => section,
          :items => section.items,
          :options => {
            :html_id => "tbl-items-"+section.menu.id.to_s,
            #:html_id => "",
            :class => "table tbl-items"}}
                                     
    end
  end


Oddly, if I set the line

:html_id => "tbl-items-"+section.menu.id.to_s,

to be

:html_id => "tbl-items-",

it will update the content correctly, but the ID will be incorrect.

The partial stuff is pretty straight forward but big, here's the relevant part:

<div id="tbl-items-<%= menu.id -%>" class="table tbl-items">

# content.....
</div>


Any thoughts on what is happening here?