From 4a836cb285934939339bcd8940fac7be354ec4b6 Mon Sep 17 00:00:00 2001 From: Adi Dahiya Date: Fri, 5 Dec 2014 17:32:35 -0500 Subject: [PATCH] Fix selectize.js API typings - Make event handler types less restrictive --- selectize/selectize-tests.ts | 13 ++++++++++++- selectize/selectize.d.ts | 11 +++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/selectize/selectize-tests.ts b/selectize/selectize-tests.ts index 6c0ae26d4..b5ea65829 100644 --- a/selectize/selectize-tests.ts +++ b/selectize/selectize-tests.ts @@ -1,7 +1,18 @@ /// /// -// All code examples taken from https://github.com/brianreavis/selectize.js/blob/master/examples +var $input = $(".test-input").selectize(); +var testApi = $input[0].selectize; + +function changeListener(selection: string) { + console.log(selection); +} + +testApi.on("change", changeListener); +testApi.off("change", changeListener); +testApi.off("change"); + +// All code examples below taken from https://github.com/brianreavis/selectize.js/blob/master/examples // API example // -------------------------------------------------------------------------------------------------------------------- diff --git a/selectize/selectize.d.ts b/selectize/selectize.d.ts index bf3950941..e8eed2c1b 100644 --- a/selectize/selectize.d.ts +++ b/selectize/selectize.d.ts @@ -445,17 +445,12 @@ declare module Selectize { /** * Adds an event listener. */ - on(eventName: string, handler: (event: JQueryEventObject) => any): void; + on(eventName: string, handler: Function): void; /** - * Removes an event listener. + * Removes an event listener. If no handler is provided, all event listeners are removed. */ - off(eventName: string, handler: (event: JQueryEventObject) => any): void; - - /** - * Removes all event listeners. - */ - off(eventName: string): void; + off(eventName: string, handler?: Function): void; /** * Triggers event listeners.