select2 database

0

I have a select2 that is populated from the database everything works, receives data from the bank, and so on. but if I want to edit it does not bring the option saved on the screen only on the front if it is debugged it is already in the normal select it brings face understand

this is javascript

     $('.js-single').select2({
        allowClear: true,
        selectOnClose: true,
    })

this is the html

<div class="es2 col-md-6">
              <label class="lb">País<label class="lb1" data-
            toggle="tooltip"
                title="ÁREA DE TEXTO OBRIGATÓRIO"> *</label></label> 
              <select data-toggle="tooltip"
                title="ÁREA DE TEXTO OBRIGATÓRIO" required="required"
                ng-model="pessoa.pessoasEnderecos.pais.idPais"
                ng-options="pai.idPais as pai.nome for pai in paises " 
              class="js-single"
                style="width: 100%; margin-top: -10px;" id="paisPais">
                <option ></option>
              </select>
            </div>

If anyone can help me

    
asked by anonymous 15.02.2018 / 13:46

1 answer

0

After changing the angle value, trigger the change.select2 event of the select2 itself

$('#paisPais').trigger('change.select2');

So the value will be updated throughout the structure of the element, including the spans you commented on.

    
15.02.2018 / 14:30