Ich versuche, fontawesome Symbole in den Select2 v4 Dropdown-Elementen anzuzeigen. Aber das Dropdown-Menü zeigt den HTML-Code an und erzeugt nicht das eigentliche Icon. Diese Methode funktioniert mit select2 V3, scheint aber nicht mit v4 zu funktionieren. Jede Hilfe wird geschätzt. DankeFügen Sie fontawesome Symbole in select2 V4 Dropdown-Elemente hinzu
HTML
<div class="select2-wrapper">
<select class="input icons_select2">
<option value="fa-dribbble" data-icon="fa-dribbble">Dribbble</option>
<option value="fa-dropbox" data-icon="fa-dropbox">Dropbox</option>
<option value="fa-facebook" data-icon="fa-facebook">Facebook</option>
</select>
</div>
JS
function iformat(icon) {
var originalOption = icon.element;
return '<i class="fa ' + $(originalOption).data('icon') + '"></i> ' + icon.text;
}
$('.icons_select2').select2({
width: "100%",
templateSelection: iformat,
templateResult: iformat
});
Siehe die Geige für ein Beispiel: http://jsfiddle.net/qCn6p/206/
Wie ich FontAwesome in Eingabe der Suche nach select2 hinzufügen können? – huykon225