Backbone.js Advent Calendarの15日目です。軽めにいきます。 Backbone.Modelのattributesにオブジェクトを設定するときの注意点など。attributesはsetとかで設定される値をオブジェクトして持っているやつです。 まず次のようにsetでattributesを設定します。 var MyModel = Backbone.Model.extend(); var m = new MyModel(); m.set('hoge', 'fuga'); m.set('foo', { bar: 'baz' }); このようにhogeには文字列、fooにはオブジェクトを設定しました。そしてtoJSONでattributesを取得して値を更新してみます。 var attrs = m.toJSON(); attrs.hoge = 'new fuga'; attr
![Backbone.Modelのattributesにオブジェクト入れるときの注意 - Webtech Walker](https://cdn-ak-scissors.b.st-hatena.com/image/square/c4c16447eff126477daf44f3258b48b98d139942/height=288;version=1;width=512/http%3A%2F%2Fwebtech-walker.com%2Fimg%2Fcommon%2Ficon.png)