chaplinjs / chaplin-boilerplate-plain

Boilerplate application for the Chaplin.js library – written in plain JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HelloWorld initialize method causes infinite loop

chreke opened this issue · comments

Uncommenting these lines in models/hello_world.js causes the application to go into an infinite loop:

//,initialize: function(attributes, options) {
  //Model.apply(this, arguments);
  //console.debug('HelloWorld#initialize');
//}

I haven't gone really deep into this but I guess the underlying cause is that calling Model.apply calls the Model's constructor, which in turn calls initialize with the new HelloWorld as its context?

Replacing Model.apply with Model.prototype.initialize.apply solves the problem, but I'm not sure if this is a 100% reflection of what's happening in the Coffeescript example? (I'm a bit of a Coffeescript noob, sorry about that)

That’s right. Fixed.

Wow, that was quick! Thanks! :)