As the title describes it I'm having an issue with select boxes and firing the change event on them on iOS Safari. I've got the following code:
$thisPage.find('select#id-attribute').on('change', function (e) {
var theId = $(this).val();
$thisPage.find('.place-where-options-get-populated').empty();
if (theId != '') {
$.ajax({'type': 'GET', 'url': '/the-actual-url'+ theId, 'dataType': 'json'})
.done(showTemplate)
.fail(function(jqXHR, textStatus, errorThrown) {
})
} else {
showTemplate({});
}
}).trigger('change');
The above code works fine on desktop browsers -the output options change accordingly on each change event- whereas on iOS the options only change every second time (works on first change, doesn't on the second, works on the 3rd, doesn't on the 4th, etc). I'm using jQuery v3.2.1
A guide in the right direction would be highly appreciated.
Edit: showTemplate() function is basically the requests which I'm doing to the server and it ends in the following (the part which has to do with my issue):
$thisPage.find('.place-where-options-get-populated').html(theItems);
Now, if do a console.log on 'theItems' this always returns what it should return. Furthermore the content actually gets added to its appropriate container, just that it doesn't show up on the page.