Permalink
Browse files

Fix for callbacks being wrongly called on multiple instances - they w…

…ere being stored on the prototype and thus being shared across instances.
  • Loading branch information...
1 parent 662bc9d commit 07f790c3c5a3e17c1a965ecf319b1f72663b7796 @benpickles committed Jul 10, 2010
Showing with 5 additions and 2 deletions.
  1. +2 −0 CHANGELOG.markdown
  2. +3 −0 src/model.js
  3. +0 −2 src/model_callbacks.js
View
@@ -1,5 +1,7 @@
# Changelog
+* Fix for callbacks being wrongly called on multiple instances - they were being stored on the prototype and thus being shared across instances. Thanks to Oliver Nightingale for identifying the bug and writing a test case.
+
## 0.8.4
* Add named parameters to `Model.RestPersistence` so "/categories/:category_id/posts" will pick up the corresponding `category_id` attribute from your model and be converted to "/categories/2/posts". [Russell Jones]
View
@@ -5,10 +5,13 @@ var Model = function(name, class_methods, instance_methods) {
// The model constructor.
var model = function(attributes) {
this.attributes = attributes || {};
+ this.callbacks = {}
this.changes = {};
this.errors = new Model.Errors(this);
};
+ model.callbacks = {}
+
// Apply class methods and extend with any custom class methods. Make sure
// vitals are added last so they can't be overridden.
jQuery.extend(model, Model.Callbacks, Model.ClassMethods, class_methods, {
View
@@ -1,6 +1,4 @@
Model.Callbacks = {
- callbacks: {},
-
bind: function(event, callback) {
this.callbacks[event] = this.callbacks[event] || [];
this.callbacks[event].push(callback);

0 comments on commit 07f790c

Please sign in to comment.