Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update small portion of view in Backbone or Spine

The common pattern in Backbone/Spine is to re-render the whole view from scratch when something happens.

But what do you do if you only need to update a small part of it (highlight, select, disable, animate etc)?

It doesn't make any sense to re-render everything as it might screw up the current layout (If the page has been scrolled to a certain point for example).

On the other hand if you update small parts "inline" from the View using something like $('.selected').highlight(), then you would have to duplicate the same logic in the view template and JavaScript code.

So what is the "best practice" in Backbone/Spine to do that?

like image 792
Dmytrii Nagirniak Avatar asked Oct 01 '11 11:10

Dmytrii Nagirniak


1 Answers

In Spine, use the element pattern: http://spinejs.com/docs/controller_patterns

like image 178
Alex MacCaw Avatar answered Jan 02 '23 06:01

Alex MacCaw