Skip to content

Comment on Why I switched to Spine.jsparent

Comments

Great teardown.

Could you (or anyone else) elaborate on how would you refactor storing references to model id's in DOM?

How do I get the proper model instance in my event handler without using attributes? If I have collection view that renders a list, for example. What are the other options I even have then?

Thanks!

Your collection view should render multiple item views. You pass the model instance to each item view, and then the view handles all the event bindings, and the model is scoped to `this`

EDIT: This way if you update that one model, you're only calling one view's render method. Each view sets up it's own bindings, and when the view is removed, it can remove just the bindings on itself.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.