mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
eventName should be an object to support multiple event names: see code below taken from Backbone code base
// Bind an event to a `callback` function. Passing `"all"` will bind
// the callback to all events fired.
on: function(name, callback, context) {
if (!eventsApi(this, 'on', name, [callback, context]) || !callback) return this;
========
// Implement fancy features of the Events API such as multiple event
// names `"change blur"` and jQuery-style event maps `{change: action}`
// in terms of the existing API.
var eventsApi = function(obj, action, name, rest) {
if (!name) return true;
// Handle event maps.
if (typeof name === 'object') {
for (var key in name) {
obj[action].apply(obj, [key, name[key]].concat(rest));
}
return false;
}
Signed-off-by: areel <aidanreel@gmail.com>
This commit is contained in:
Vendored
+1
-1
@@ -67,7 +67,7 @@ declare module Backbone {
|
||||
}
|
||||
|
||||
class Events {
|
||||
on(eventName: string, callback: (...args: any[]) => void , context?: any): any;
|
||||
on(eventName: any, callback: (...args: any[]) => void , context?: any): any;
|
||||
off(eventName?: string, callback?: (...args: any[]) => void , context?: any): any;
|
||||
trigger(eventName: string, ...args: any[]): any;
|
||||
bind(eventName: string, callback: (...args: any[]) => void , context?: any): any;
|
||||
|
||||
Reference in New Issue
Block a user