Skip to content

Instantly share code, notes, and snippets.

@ykhs
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ykhs/f64df63c8e223c3d00aa to your computer and use it in GitHub Desktop.
Save ykhs/f64df63c8e223c3d00aa to your computer and use it in GitHub Desktop.
JavaScript養成読本 特集1 第4章 リスト3 訂正
var ContactView = Backbone.View.extend({
render: function() {
// HTMLテンプレートを取得する
var template = $('#contact-template').html();
// HTMLテンプレートにモデルのデータを適用する
// モデルのtoJSON()メソッドを使って属性を
// オブジェクトの形式で書き出す
var compiled = _.template(template)
var html = compiled(this.model.toJSON());
// 自身が保持しているDOM要素を更新する
this.$el.html(html);
return this;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment