theInternauts / post-it-notes

experiments with DOM manipulation, OO JS, and data models
6 stars 0 forks source link

Posts in a group don't close properly is PostGroup.render() is called more than once #8

Open theInternauts opened 10 years ago

theInternauts commented 10 years ago

State: a post group exists with multiple posts rendered in its container.
PostGroupView.render() has been called once (at initialization of the group view). At that point the allPostModels collection was empty.

When posts are dragged into the group, the allPostModels collection i populated. Events work fine at this point. The problem happens when .render() is called on the group and the posts DOMs are destroyed and then re-rendered. The listeners don't seem to be re-attached properly (or at all).

Guess: there's an issue with the this.$el.empty() clearing the DOM in a dirty way. Maybe I need to unbind events or destroy the post views directly from their view instances with view.remove().

theInternauts commented 10 years ago

After a post group is re-rendered, the events on the post are not re-registered or delegated. Check here for more details: http://backbonejs.org/#View-render, http://backbonejs.org/#View-delegateEvents

Double check conventions for handling nested views. Consider Backbone Marionette.