javascript - Is there a standard design pattern for dealing with views that have both read and write states? -


i'm wondering if there standard design patterns employed backbone (and similar) community whole reflect "best practice" readability , design respect view components not presents data end-user allows editing contents. user toggle between read-and-write presentations interacting link, or button. example of type of behavior i'm thinking of stack overflow career's site permits edit entries , switches between read-and-write contexts.

as see if there 2 approaches:

  1. create template includes read-only data <form> in single template , wire show/hide functionality.
  2. create two separate views, 1 read-only data , other <form>, , render both independently.

are there others? there preference has emerged in community on how design pattern should approached?

if change on presentation layer should change model (on events example). can manager @ view. example:

    vare view = backbone.view.extend({     classname: 'panel-body',      template: 'datalibrary/dl-upload-form-file-view',      events: {         'change .someselector': 'somehandler'     },      initialize : function(){        this.listento(this.model,'change','modelchangehalder')      }      somehandler: function(e){        // update model here     },      modelchangehalder : function() {        // updates on model change     } 

once have state model can play around wan't , perist server, save storage or whatever want.

also take @ backbone.controller project. allows add c backbones mv* pattern. in case able manage view-model relations inside controller, in opinion it's better approach.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -