New callback to allow user to customize templates.

This commit is contained in:
fabien.leconte 2016-09-30 09:40:06 +02:00
parent 54510a2671
commit c8d508f4de

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);
}
/**