callbacks for select2 can now handle numeric values for data attributes

This commit is contained in:
Uwe Steinmann 2019-06-13 09:29:24 +02:00
parent f32ac518ea
commit 556ec6de14

View File

@ -5,8 +5,12 @@
* (see https://forums.select2.org/t/propperly-escape-option-value-to-prevent-xss/788)
*/
chzn_template_func = function (state) {
var subtitle = $(state.element).data('subtitle');
var warning = $(state.element).data('warning');
var subtitle = '';
if($(state.element).data('subtitle'))
subtitle = $(state.element).data('subtitle')+''; /* make sure it is a string */
var warning = '';
if($(state.element).data('warning'))
warning = $(state.element).data('warning')+''; /* make sure it is a string */
var html = '<span>'+state.text.replace(/</g, '&lt;')+'';
if(subtitle)
html += '<br /><i>'+subtitle.replace(/</g, '&lt;')+'</i>';