Ich bin mit jQuery Autocomplete ich einige Code haben. Ich habe versucht, "Quelle" Autovervollständigung durch Auswahl ändern, aber wenn ich Quelle Autovervollständigung ändern nicht funktionieren. Ich versuche, .change, .on, .click für reinitialisiert, aber immer noch nicht funktioniert. Wenn ich nicht modifizierte Quelle verwende, funktioniert Autocomplete gut.ändern und neu initialisiert die automatische Vervollständigung
$('#myselect').change(function() {
$('#part_q').prop("disabled", false).focus();
var brand = $('#myselect').val();
$('#part_q').autocomplete({
source: 'https://example.com/search/?' + brand
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<select id="myselect">
<option value="" selected="selected" disabled="">Select Brand</option>
<option value="1">Some brand</option>
<option value="2">Some brand 2</option>
<option value="3">Some brand 3</option>
</select>
<input disabled="" placeholder="Model Name" type="text" id="part_q" name="part_q">
Für mich wichtig, dass die Parameter zu speichern. "Quelle: 'https: //example.com/search/?' + Marke" weil dort dynamischer Wert. By the way, in stackoverflow es funktioniert ... wenn Eingabe ändern, Autocomplete arbeiten ... seltsam. .. –
@AleksandrPetric ja, also benutze die URL anstelle des Arrays, das ich benutzt habe! like '(" option ", {source:" example.com/search/?"+brand}); ' –
@AleksandrPetric hat das Problem vollständig gelöst? –