Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

224
Vistas
jquery autocomplete not working in full screen browser

I have implemented autocomplete with jQuery AJAX. It's working fine when the screen size is half but while the screen size is full it's not working.

Another problem is that it doesn't show the result in the first input; it takes some time or when I remove the first attempt and type again in the input then autocomplete suggests result.

$(document).ready(function() {
  $("#purchase_item_search").on('keyup', function() {
    var arrayReturn = []
    $.ajax({
      url: "/products",
      dataType: 'json',
      success: function(data) {
        for (var i = 0; i < data['products'].length; i++) {
          var id = (data['products'][i].id).toString();
          arrayReturn.push({
            'data_id': id,
            'value': data['products'][i].name,
            'name': data['products'][i].name,
            'price': data['products'][i].purchase_price,
            'discount': data['products'][i].discount,
            'tax': data['products'][i].tax_id,
          })
          printProduct(arrayReturn);
        }
      }
    });

    function printProduct(arrayReturn) {
      $('#purchase_item_search').autocomplete({
        source: arrayReturn,
        select: function(event, products) {
          // Set selection
          $('#purchase_item_search').val(''); // display the selected text
          createRow(products);
          return true;
        }
      });
    }

    const tbody = document.getElementById('item_list');

    function createElement(tagName, id, className, innerHTML) {
      const element = document.createElement(tagName)
      element.id = id || ''
      element.className = className || ''
      element.innerHTML = innerHTML || ''
      return element
    }

    function createRow(products) {
      // ...
    }
  });
});
<link rel="stylesheet" href="https://code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="{{ asset('assets/backend/bundles/libscripts.bundle.js') }}"></script>
<script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"></script>

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda