3 ms·
Absolutely. I'm not saying you should have a single gigantic render method that gets called for every single change. We use a very similar pattern to what @tris
by ianstormtaylor 14y ago
Absolutely. I'm not saying you should have a single gigantic render method that gets called for every single change. We use a very similar pattern to what @tristan_juricek mentions with small render helpers that get bound as change callbacks. (I'll probably write about that one next.) But since I was talking about subviews I didn't want to go into the non-subview render bits which would be where you'd want render helpers.
Regardless, I'd still have the single `render` as a parent method that renders the initial template via `$.html()` so that my render helpers aren't appending their bits into the DOM. And that parent method still shouldn't break everything if it's called twice.
And then if you wanted to be safe, you could have the render helpers check to see if the view is `rendered` before attempting to do their bit. (And `return this.render();` instead if it isn't yet rendered.)