I have an array with some objects that have the same "id" property like this :
var regions = [
{'id': 1, 'value': 'Ankara'},
{'id': 2, 'value': 'İstanbul'},
{'id': 2, 'value': 'Istanbul'}
]
I try to display only the first object of a certain ID if there are duplicate (in this case I want to display 'İstanbul' but not 'Istanbul'). I tried to use a function inside the source property but I failed and I'm not sure to understand where I need to do this ... Here is a snippet :
var regions = [
{'id': 1, 'value': 'Ankara'},
{'id': 2, 'value': 'İstanbul'},
{'id': 2, 'value': 'Istanbul'}
]
$('#myInput').autocomplete({
source: regions
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<input type="text" placeholder="type here ..." id="myInput">
Any help would be appreciate. Thank you.