привет, я пытаюсь добавить изображение в раскрывающемся списке. Я использую select2 lib для создания моего списка.
select2 Версия: 3.5.4 (я не могу обновить)
ОБНОВЛЕНИЕ мой код привет, спасибоза вашу помощь ... @ SachaM78 я обновляю свой код
jQuery(document).ready(function() {
fcfield_addrint.initAutoComplete("custom_field17_0", "field17");
fcfield_addrint.initMap("custom_field17_0", "field17");
// load image in select
function format(state) {
console.log(state);
if (!state.id) return state.text; // optgroup custom_field17_0_custom_marker
return (
'<img class="fla" src="images/icons/' +
state.id.toLowerCase() +
'.png"/>' +
state.text
);
}
$("#custom_field17_0_custom_marker").select2({
formatResult: format,
formatSelection: format,
escapeMarkup: function(m) {
return m;
}
});
});
и
<select id="custom_field17_0_custom_marker" name="custom[field17][0][custom_marker]" class="fc_gm_custom_marker" aria-invalid="false">
<option value="">Select</option>
<option value="http://localhost/flexi-dev/\images/icons-map/2hand.png">2hand.png</option>
<option value="http://localhost/flexi-dev/\images/icons-map/360degrees.png">360degrees.png</option>
<option value="http://localhost/flexi-dev/\images/icons-map/_readme-license.txt">_readme-license.txt</option>
<option value="http://localhost/flexi-dev/\images/icons-map/abduction.png">abduction.png</option>
<option value="http://localhost/flexi-dev/\images/icons-map/aboriginal.png">aboriginal.png</option>
<option value="http://localhost/flexi-dev/\images/icons-map/accesdenied.png">accesdenied.png</option>
</select>
, которые возвращают
index.php? option = com_flexicontent & task= item.edit & view = item & id = 13: 824 Uncaught TypeError: Невозможно прочитать свойство 'select2' из null в HTMLDocument.(index.php? option = com_flexicontent & task = item.edit & view = item & id = 13: 824) в u (jquery.min.js? a84f5770d385cc79fd5efcfeaebe6f82: 2) в Object.fireWith [as resolWith] (jquery.min.js) в Function.ready (jquery.min.js? a84f5770d385cc79fd5efcfeaebe6f82: 2) в HTMLDocument._ (jquery.min.js? a84f5770d385cc79fd5efcfeaebe6f82: 2)