Z
Z
zlFast2016-04-07 18:38:46
JavaScript
zlFast, 2016-04-07 18:38:46

How to work with a view in backbone?

Can you please tell me how to correctly change the data on the view using the backbone?
I try via this.model.set() but the data on the page doesn't change. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Niomin, 2016-04-07
@Niomin

You need to subscribe the view to changes in model.

K
Konstantin Kitmanov, 2016-04-07
@k12th

There is no single right way. The simplest and most common is something like this:
Accordingly, when we do this.model.set, the entire view is re-rendered. Sometimes, for performance reasons, only those attributes that are actually displayed in the view are listened for.
What exactly is your reason - it's impossible to say without code. Try to reproduce the problem on the minimum amount of code, either you yourself will figure it out in the process, or you can show it to others.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question