I have two models: Child and Day. A Child has many days, and a day
belongs to a child.
I want to create ana ajax table listing the children and, after pressing
a button, I want to show the days that belong to that child.
Here is my code:
(list.rhtml)
<table>
<tr>
...
<td><%= link_to ''Days'', :action =>
''show_days'', :id => child %></td>
</tr>
<tr>
<div id="show_days" style="display:
none"></div>
</tr>
</table>
(child_controller
def show_days
@child = Child.find(params[:id])
@days = @child.days
end
(child.chow_days.rjs)
page.replace_html ''show_days'', :partial =>
''days'', :collection => @days
page.visual_effect :toggle_appear, ''show_days'',
''duration'' => 0.5
(_days.rhtml)
<% for day in @days -%>
<td><%=h day.startdate %></td>
<td><%=h day.enddate %></td>
<% end -%>
The problem is, in Firefox I get a new page with the following text:
try {
Element.update("show_days", " <td>2005-09-01</td>\n
<td>2006-07-01</td>\n");
Effect.toggle("show_days",''appear'',{duration:0.5});
} catch (e) { alert(''RJS error:\n\n'' + e.toString());
alert(''Element.update(\"show_days\", \"
<td>2005-09-01</td>\n
<td>2006-07-01</td>\n\");\nEffect.toggle(\"show_days\",\''appear\'',{duration:0.5});'');
throw e }
What am I doing wrong?
--
Posted via http://www.ruby-forum.com/.