0
正如标题所描述的,我在选择框和在iOS Safari上触发更改事件时遇到问题。 我有下面的代码:jQuery选择更改在iOS上每隔一次触发
$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输出选项,每个变化事件 - 发生相应的变化,而iOS上的选项只改变每一秒的时间(适用于第一个变化,不在第二个,在第3个工作,不在第4个,等等)。 我正在使用jQuery v3.2.1
正确的方向指南将受到高度赞赏。
编辑: showTemplate()函数基本上是我正在做的服务器的请求,并在下面的(这与我的问题做部分)结束:
$thisPage.find('.place-where-options-get-populated').html(theItems);
现在,如果在'theItems'上做一个console.log,它总是返回它应该返回的内容。此外,内容实际上被添加到适当的容器中,只是它不会显示在页面上。
ajax请求上的showTemplate做什么 –
对你有用的链接https://stackoverflow.com/questions/5960731/strange-behavior-of-select-dropdowns-onchange-js-event-when-using-next- on-m – PraveenKumar
@lgkarolos - 请参阅我的文章的编辑部分。 – Seb