Problems with select2: does not show results with JQuery

1

I am using select2 , you search me well but you do not show me the results.

On the other hand, how do I make it so that when I click on some product result, I automatically put the price and the amount in input of the side? My SQL already brings all the data, in the image I only brought the name because I thought the problem was that.

HELP WITH THIS PLEASURE

HTML

<div class="col-xs-12">
    <div class="col-md-6">
        <div class="form-group">
            <label class="control-label col-md-4">Producto</label>
            <div class="col-md-12">
                <select class="form-control select2" id="producto" name="Ingrese el nombre del Producto" style="width: 100%"></select>
                <span class="help-block"></span>
            </div>
        </div>
    </div>
    <div class="col-md-3">
        <div class="form-group">
            <label class="control-label col-md-4">Precio</label>
            <div class="col-md-12">
                <input id="precio" placeholder="0" class="form-control" type="text">
                <span class="help-block"></span>
            </div>
        </div>
    </div>
    <div class="col-md-3">
        <div class="form-group">
            <label class="control-label col-md-4">Cantidad</label>
            <div class="col-md-12">
                <input id="cantidad_stock" placeholder="0" class="form-control" type="text">
                <span class="help-block"></span>
            </div>
        </div>
    </div>
</div>

JQUERY

$(document).ready(function () {

    //******* CENTRAL EL FOCUS EN EL  select2 ********//
    //$.fn.modal.Constructor.prototype.enforceFocus = $.noop;
    $("#producto").select2({
        placeholder: "Buscar proceso",
        allowClear: true,
        minimumInputLength: 1,
        ajax: {
            url: baseurl + "Venta/obtener_producto",
            dataType: "json",
            delay: 250,
            data: function (params) {
                return {
                    q: params.term
                };
            },
            processResults: function (data) {
                return {
                    results: data
                };
            },
            cache: true
        },
    });
});

    
asked by Joel More F. 09.06.2017 в 23:28
source

0 answers