rendrjs / rendr

Render your Backbone.js apps on the client and the server, using Node.js.
MIT License
4.09k stars 312 forks source link

Fix view hierarchy rendering order when rendering from the client #474

Closed ingiulio closed 9 years ago

ingiulio commented 9 years ago

When calling this.app.router.redirectTo('some/path') from the client, the rendering order of views in a parent-child view hierarchy is often not correct. This is happening because in _postRender we call attachChildViews and then immediately trigger the postRender event, without waiting for attachChildViews itself to be completed. In AMD environment, this often results in child views firing postRender before parent views, or in random order anyway. The solution is as simple as firing postRender only when the child views are attached, using a callback for it.

Please let me know if this is not clear. What do you think?

coveralls commented 9 years ago

Coverage Status

Coverage increased (+0.01%) to 84.52% when pulling e95f4300a889e321bbfc20e4a55fa5de65105f34 on ingiulio:attachChildViewsOrderOnClientSide into 2b07b947f98a9d2d57ee1be98bc7d6e578fa5c01 on rendrjs:master.

pjanuario commented 9 years ago

:+1:

saponifi3d commented 9 years ago

Looks great! Nice find too. :+1: