documentcloud/backbone — Issue #931: Model prototype missing after clone() in combination with bindAll(this).
Author: reinierkip
Created: 2012-02-02 13:15:49+00:00
State: open

I've got a case where the model's prototype (or something like that) is missing after `model.clone()`.

**Platform**
Windows 7
Chrome 16.0.912.77 m *and* Firefox 9.0.1.

**Example**

```javascript
var A = Backbone.Model.extend({
initialize: function () { _.bindAll(this); },
hello: function () { console.log("Hello, world!"); }
});
var B = A.extend({
initialize: function () { _.bindAll(this); }
});

// TypeError: Object [object Object] has no method 'hello'
new B().clone().hello();
```

If one doesn't `bindAll()` in B's `initialize`, the problem goes away.

While writing this report I feel that `B#initialize()`'s `bindAll()` messes up `B#clone()`. Replacing `bindAll()` with specific `bind()`s seems to be a solution. Still, maybe this should still be fixed.