Reputation: 12252
$("#todos").append($("<%= escape_javascript(render("todo")) %>").find("form:eq[0]").children());
I'm sure the rendered partial has a form tag and it has child content, and yet, nothing gets added into #todos
.
EDIT: Here's what is rendered by escape_javascript(render("todo"))
$("#todos").append($("<div class=\'todo\'>\n <form accept-charset=\"UTF-8\" action=\"#\" class=\"new_todo\" id=\"new_todo\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /><input name=\"authenticity_token\" type=\"hidden\" value=\"5jeoteBl1GwCw6t4jllDRVuragGoRh3wiodOV8jMgOQ=\" /><\/div>\n <p>make laundry<\/p>\n <\/form>\n<\/div>\n").find("form:eq[0]").children());
Upvotes: 1
Views: 541
Reputation: 5832
MaybeMost probably it doesn't work because you used square brackets instead of round ones in find()
Should be
.find('form:eq(0)').children()
Upvotes: 2