Backbone.js: avoid view→model→view double conversion

后端 未结 3 663
庸人自扰
庸人自扰 2021-02-15 17:34

I’m trying to build this:

When I edit field on the left it should update the one on the right and vice-versa.

  • Editing a value in an input field cause

3条回答
  •  太阳男子
    2021-02-15 17:50

    Here's my take on this; instead rendering the whole view on every change, in interactive views, use the view's jQuery or plain JS contexts just like your non-MVC example.

    http://jsbin.com/fomugixe/1/edit

    As the Backbone docs say:

    "Two way data-binding" is avoided. While it certainly makes for a nifty demo, and works for the most basic CRUD, it doesn't tend to be terribly useful in your real-world app. Sometimes you want to update on every keypress, sometimes on blur, sometimes when the panel is closed, and sometimes when the "save" button is clicked.

提交回复
热议问题