以下の内容はhttps://anton0825.hatenablog.com/entry/20130730/1380818612より取得しました。


backbone.jsのcollectionオブジェクトにpushしたら_byIdがundefined

pushのタイミングで以下のエラーが出た。

TypeError: Cannot read property '#<Ohlc>' of undefined

色々調べたら、コンストラクタの最初でsuper呼べと書いてあったので呼ぶと直った。↓のような感じ。

exports.OhlcCollection = class OhlcCollection extends Backbone.Collection
  model:Ohlc
  constructor: (models, @options) ->
    super models, @options

constructorの代わりにinitializeを使えばsuper呼ばなくていいし、その方が主流っぽいのでそっちにした。
参考:javascript - Backbone.js collection fetch 'this._byId' undefined - Stack Overflow




以上の内容はhttps://anton0825.hatenablog.com/entry/20130730/1380818612より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14