2
I am doing internationalization with the lib i18next, everything goes right, it translates puts the values within the select2
, but the first value is not shown in any way, even if I open the select2
and clicking on the first item. Does anyone have any idea what might be going on?
HTML:
<html>
<head><title>Select2</title></head>
<body>
<div>
<label class="col-sm-12 text-white" style="text-align: left;" data-i18n="store.tipo"> </label>
<div class="col-sm-12">
<select id="selectTipo" class="form-control"></select>
<br/>
<br/>
</div>
</div>
<script src="~/lib/jquery.js" type="text/javascript"></script>
<script src="~/lib/select2.js" type="text/javascript"></script>
<script src="~/js/arquivo.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
GetTipo();
})
</script>
</body>
</html>
Javascript: (js file.)
function GetTipo(){
var $selectTipo = $('#selectTipo');
$selectTipo.append($('<option data-i18n="store.comboTipos.todos">', { value: "0", text: $(this).data('data-i18n')}));
$selectTipo.append($('<option data-i18n="store.comboTipos.painel">', { value: "1", text: $(this).data('data-i18n') }));
$selectTipo.append($('<option data-i18n="store.comboTipos.report">', { value: "2", text: $(this).data('data-i18n') }));
$selectTipo.append($('<option data-i18n="store.comboTipos.notificacao">', { value: "3", text: $(this).data('data-i18n') }));
$selectTipo.append($('<option data-i18n="store.comboTipos.auditoria">', { value: "4", text: $(this).data('data-i18n') }));
$selectTipo.append($('<option data-i18n="store.comboTipos.apresentacao">', { value: "5", text: $(this).data('data-i18n') }));
$selectTipo.val("0").trigger("change");
$selectTipo.select2();
}
IMAGE:
JSFIDDLE: (link solved)
You can make a fiddle out of it?
– MoshMage
Done, this at the end of the question
– Danilo Pádua
In fiddle with
select2
I don’t see anything.– Jorge B.
Because eh, that’s the problem, here in my the lib Select2 was working more was not loading the data, now neither ta working
– Danilo Pádua
Now it’s working, look at it. Try to help me because it doesn’t load the items in the combo
– Danilo Pádua