5
Ich habe eine select:
Wie füge ich ein Bild in Select2 Optionen hinzu?
<select data-bind="options : PeriodeOptions, optionsValue : 'Periode',
optionsText : function(item) { return AddLock(item)}" id="SelectPeriode"></select>
Und ich habe meine fucntion;
//am - Fonction permettant d'ajouter le cadenas à côté de la Periode si elle est cloturée
function AddLock(pItem) {
if (!pItem.IsCloturePeriode)
return pItem.Periode;
var lTemplate = $('<span>' + pItem.Periode + '<img src="/Ressources/Images/Locked.png"/></span>');
return lTemplate;
};
Es sendet mir ein Objekt:
Bitte um Hilfe!
Ja ich habe eine select2 Funktion, es ist nur nicht im Code angezeigt. Ich fand tatsächlich die Lösung, es ist ähnlich wie deine, aber ich mag deine mehr. Ich habe: '' - Ich verließ Optionen und optionValue (entfernte OptionText). Und in templateResult und templateSelection ich tat: 'function (item) {var lTemplate = $ ( '' + item.text + '' ); Rückgabe lTemplate; }, ' –