I have a select element and I need to search the options not only for the text, but also for the title (or any other attribute), I have already been able to put the title to appear when the element expands, but I can not do a search on it.
I'm using the select2 plugin in version 3.5.2
<select id="estado" class="form-control">
<option value="SP" title="São Paulo">SP</option>
<option value="RJ" title="Rio de Janeiro">RJ</option>
<option value="SC" title="Santa Catarina">SC</option>
</select>
$("#estado").select2({
formatResult : function(item) {
var markup = '<div class="row">' +
'<div class="col-lg-12">' + item.text + '</div>' +
'</div>' +
'<div class="row">' +
'<div class="col-lg-12 text-muted">' + item.element[0].title + '</div>' +
'</div>';
return markup;
}
});
Follow the example by running on jsfiddle