I am using RoR with AJAX to create posts. So I need an ability to add an 'answers' by previous id.
Every time submit button clicked following code being called
$("<%= selector %>").append("<div id='<%= newanswer %>'><%= escape_javascript(render('answer_layout')) %></div>");
where
selector
looks like this #answer-12
newanswer
would be #answer-13
First time it works as suggested, but when I click submit second time I need to use already appended #answer-13
div to append newly #answer-14
, and it doesn't work. I understand that document doesn't know about first appended element, but have no idea how to resolve this issue. Thanks for any help.
No comments:
Post a Comment