バックボーンビューに奇妙な動作が見られます。console.log "this.model"を実行すると、renderメソッドとカスタムメソッドの1つで異なる結果が得られます。
これが私のルートを設定する方法です:
app_router.on('route:showTemplates'、function(id){ var listtemplate = new ListTemplateModel.Model({ やった }); listtemplate.fetch()。then(function(){ var detailsview = new ListDetailsView.View({ モデル:listtemplate }); }); });
ビューのrenderメソッドでconsole.logを実行すると、期待どおりの結果が得られます。
define(['use!backbone'、'helpers / templateHelper']、function(B、TemplateHelper){ var View = B.View.extend({ el:'#page'、 テンプレート:TemplateHelper('taskDetailTemplate')、 イベント:{ 'keypress#new-step':'addOnEnter' }、 初期化:function(){ this.render(); }、 レンダリング:function(){ this。$el.html(this.template(this.model.toJSON())); }、 addOnEnter:function(e){ this.input = this。$('#new-step'); if(e.which!== 13){// || !this.input.val()。trim()){ 戻る; } console.log(this.model.toJSON()); } }); 戻る { 表示:表示 }; });
しかし、私の「addOnEnter」メソッドのconsole.logは、セッションで作成されたすべてのモデルインスタンスの配列を返します。これは、以前に作成されたすべてのモデルに対してもイベントが発生するようなものです。