Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

show html in select2 option

var data = [{
   id: 0,
   text: 'enhancement',
   html: '<div style="color:green">enhancement</div>'
}, {
   id: 1,
   text: 'bug',
   html: '<div style="color:red">bug</div><div><small>This is some small text on a new line</small></div>'
}];

function template(data) {
    return data.html;
}

$("select").select2({
   data: data,
   templateResult: template,
   escapeMarkup: function(m) {
      return m;
   }
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #show #html #option
ADD COMMENT
Topic
Name
9+8 =