Change and reinitialized autocomplete

0

I’m use jQuery Autocomplete
I have some code.
I try modify “source” autocomplete by select, but when i change source autocomplete don’t work. I try use .change, .on, .click for reinitialized but still not working.
When i’m use not modify source, autocomplete work fine.

$('#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">

Link: Change and reinitialized autocomplete
Source: Stack Jquery

Share.

About Author

Leave A Reply