diff --git a/backbone.js b/backbone.js index a8127af0..d10093d6 100644 --- a/backbone.js +++ b/backbone.js @@ -86,6 +86,7 @@ // function. Passing `"all"` will bind the callback to all events fired. on: function(events, callback, context) { var ev; + if (!callback) return this; events = events.split(/\s+/); var calls = this._callbacks || (this._callbacks = {}); while (ev = events.shift()) { diff --git a/test/events.js b/test/events.js index bb2aeb05..2c8f3e15 100644 --- a/test/events.js +++ b/test/events.js @@ -145,4 +145,8 @@ $(document).ready(function() { equal(counter, 2, 'unbind does not alter callback list'); }); + test("if no callback is provided, `on` is a noop", function() { + _.extend({}, Backbone.Events).bind('test').trigger('test'); + }); + });