1
$("#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=\"&#x2713;\" /><input name=\"authenticity_token\" type=\"hidden\" value=\"5jeoteBl1GwCw6t4jllDRVuragGoRh3wiodOV8jMgOQ=\" /><\/div>\n    <p>make laundry<\/p>\n  <\/form>\n<\/div>\n").find("form:eq[0]").children());
2
  • Try alert($('#todos').length); Commented Jan 6, 2011 at 13:57
  • I called that before and after append line, and both alerted 1. Commented Jan 6, 2011 at 14:14

1 Answer 1

2

MaybeMost probably it doesn't work because you used square brackets instead of round ones in find()

Should be

.find('form:eq(0)').children()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.