New callback to allow user to customize templates.

This commit is contained in:
fabien.leconte 2016-09-30 09:40:06 +02:00
parent f386198ac0
commit d8ab04b7f8
4 changed files with 481 additions and 431 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -102,6 +102,7 @@ export default class Choices {
callbackOnRemoveItem: null,
callbackOnHighlightItem: null,
callbackOnUnhighlightItem: null,
callbackOnCreateTemplates: null,
callbackOnChange: null,
callbackOnSearch: null,
};
@ -2026,7 +2027,15 @@ export default class Choices {
},
};
this.config.templates = templates;
// User's custom templates
const callbackTemplate = this.config.callbackOnCreateTemplates;
let userTemplates = {};
if (callbackTemplate) {
if (isType('Function', callbackTemplate)) {
userTemplates = callbackTemplate(this, strToEl);
}
}
this.config.templates = extend(templates, userTemplates);
}
/**