Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: error input select search the second time

diconc priority asked 4 years ago


Codigo: Material Design for Bootstrap


TEST

Loading... Cercar la empresa on treballes ara. Indica nom i/o nif
Pots escollir una de les empreses que surt a continuació
Empresa on treballes actualment

const serverJsonData="https://assegurat.ccoo.cat/jsonData/"; const buscarEmpresa = serverJsonData+"service?id=54&params=:pFiltre=''SEARCH'',:pCLocal='':CLOCAL'',:pCodiCTs='':CTS''";

let callSearchEmpresa=false;

$(document).ready(function() { $('.mdb-select').materialSelect(); $( "#searchEmpresaNova" ).keyup(function() { let sBuscar=$( this ).val(); console.log("searchEmpresaNova",sBuscar,$( "#searchEmpresaNova" ).val()); setTimeout( function () { if (sBuscar==$( "#searchEmpresaNova" ).val()) { $( "#searchEmpresaNova" ).prop( "disabled", true ); console.log("Añadir a la cola ",sBuscar,callSearchEmpresa); if (!callSearchEmpresa) {
console.log("callSearchEmpresa no hay peticitones ",callSearchEmpresa); callSearchEmpresa=true; searchEmpresa(sBuscar); } } },1000); }); })

function searchEmpresa(empresa,codictreb="") { let that=this; callSearchEmpresa=true; let search=buscarEmpresa; search=search.replace("SEARCH", empresa);
search=search.replace(":CTS",codictreb); console.log("searchEmpresa",empresa,search);
if (search.length>=3) { //$("#empresaNova").materialSelect({destroy: true}); //$('#empresaNova').empty(); //$("#empresaNova").materialSelect();

    $.getJSON( search)
      .done(function(data) {    
        console.log( "buscarEmpresa success" ,data, search);
        if (data && data.empreses) {
            $('#empresaNova').empty();
            //$("#empresaNova").materialSelect({destroy: true});
            for (var x=0;x<data.empreses.length;x++) {
                $("#empresaNova").append(new Option(data.empreses[x]["nomEmpresa"],data.empreses[x]["codictreb"]));
            }
            $("#empresaNova").append(new Option("No es cap d'aquestas",""));
            //$("#empresaNova").materialSelect({destroy: false});  
        }
        $('#spinnerConsulta').hide();
      })
      .fail(function(jqXHR, textStatus, errorThrown) {
            console.log("error " + textStatus);
            console.log("incoming Text " + jqXHR.responseText);
        })
      .always(function() {
        console.log( "complete", callSearchEmpresa);
        callSearchEmpresa=false;
        $( "#searchEmpresaNova" ).prop( "disabled", false );           
        console.log( "complete", callSearchEmpresa);
      });
}

}

Cuando intento buscar una segunda vez el navegador se queda colgado, la primera vez funciona perfecto.


Tomek Makowski staff answered 4 years ago


Hi

Could you speak english?

Regards


diconc priority answered 4 years ago


Aqui os dejo un ejemplo https://marts.ccoo.cat/sample/ejemplo.html

No cambia los valores del select.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB jQuery
  • MDB Version: 4.18.0
  • Device: pc
  • Browser: chrome
  • OS: windows
  • Provided sample code: No
  • Provided link: No