Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default context for events on bind() #507

Merged
merged 1 commit into from
Jul 26, 2011
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Setting to context to this by default on bind() instead of trigger()
  • Loading branch information
shesek committed Jul 26, 2011
commit 39b36afd744b0cc218e55831c25aa7f58798317f
4 changes: 2 additions & 2 deletions backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
bind : function(ev, callback, context) {
var calls = this._callbacks || (this._callbacks = {});
var list = calls[ev] || (calls[ev] = []);
list.push([callback, context]);
list.push([callback, context||this]);
return this;
},

Expand Down Expand Up @@ -114,7 +114,7 @@
list.splice(i, 1); i--; l--;
} else {
args = both ? Array.prototype.slice.call(arguments, 1) : arguments;
callback[0].apply(callback[1] || this, args);
callback[0].apply(callback[1], args);
}
}
}
Expand Down