What is two way binding?

后端 未结 5 1326
后悔当初
后悔当初 2020-11-27 09:32

I have read lots that Backbone doesn\'t do two way binding but I don\'t exactly understand this concept.

Could somebody give me an example of how two way binding wor

5条回答
  •  隐瞒了意图╮
    2020-11-27 09:43

    McGarnagle has a great answer, and you'll want to be accepting his, but I thought I'd mention (since you asked) how databinding works.

    It's generally implemented by firing events whenever a change is made to the data, which then causes listeners (e.g. the UI) to be updated.

    Two-way binding works by doing this twice, with a bit of care taken to ensure that you don't wind up stuck in an event loop (where the update from the event causes another event to be fired).

    I was gonna put this in a comment, but it was getting pretty long...

提交回复
热议问题