diff --git a/README.md b/README.md index bfeab90..11ba237 100644 --- a/README.md +++ b/README.md @@ -376,6 +376,9 @@ classNames: { **Usage:** Classes added to HTML generated by Choices. By default classnames follow the [BEM](http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/) notation. +## Callbacks +**Note:** For each callback, `this` refers to the current instance of Choices. This can be useful if you need access to methods (`this.disable()`) or the config object (`this.config`). + ### callbackOnInit **Type:** `Function` **Default:** `null` @@ -422,7 +425,7 @@ const example = new Choices(element, { **Usage:** Function to run each time an item is unhighlighted. ### callbackOnCreateTemplates -**Type:** `Function` **Default:** `null` **Arguments:** `instance, template` +**Type:** `Function` **Default:** `null` **Arguments:** `template` **Input types affected:** `text`, `select-one`, `select-multiple` @@ -432,19 +435,19 @@ const example = new Choices(element, { ```js const example = new Choices(element, { - callbackOnCreateTemplates: function (instance, template) { - var classNames = instance.config.classNames; + callbackOnCreateTemplates: function (template) { + var classNames = this.config.classNames; return { item: (data) => { return template(` -