Hacker News new | ask | show | jobs
by superchris 5114 days ago
Read to the end, that's pretty much what I end up doing in the final version. I create the TableRowView in the helper and then listen to the parent views "rendered" event so the row view knows when it's element is in the DOM and it's safe to render itself.
1 comments

I did read to the end. What you end up suggesting includes: - rendering the view's elements as html in the parent view - creating all of the views and binding callbacks for all of the views to 'render' on the parent view - triggering all of the callbacks to render the views - each of which pull their element from the first view using a jquery selector.

I guess the advantage is that re-rendering the parent will re-render the subviews instead of re-creating them? Unless you need that, it seems to me like this is a lot of mess compared to just adding @$el.attr 'id', "row_#{@model.id}" to the child view.