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.