我有以下功能。當我點擊按鈕的時候,sweetalert2彈出窗口隨easyautocomplete列表打開。這些項目在輸入時由ajax提取。如果物品太多,並且它們不適合框中的滾動條出現。Easyautocomplete + sweetalert2 = IE 11中的消失滾動條/邊緣
我想用原來的easyatocomplete從插件 - > easyautocomplete.com < -
,但它並沒有滾動條functionality.So我環顧四周,發現這裏修改的版本:
http://gnnc.com.br/samples/easy-autocomplete/easy-autocomplete.php
問題是當我單擊滾動條滾動位置滾動條消除器和列表關閉。這個問題只發生在IE(經過測試的11和Edge)中,在FF和Chrome中是可以的。
但是!!正如我們在修改後的自動完成頁面上的演示中看到的,滾動條工作正常,即使在IE中嘗試使用鼠標滾動後也不會消失。這似乎只有在sweetalert2彈出窗口中使用時纔會發生。
這裏是我寫的代碼:
function addEmployeeByName() {
swal({
title: 'Add employee by name',
html: 'Select employee<input type="text" name="empList" id="empList" class="form-control"><input type="hidden" id="rcp">',
type: '',
confirmButtonText: 'Add employee',
confirmButtonColor: '#00A65A',
onOpen: function() {
window.setTimeout(function() {
$("input#empList").focus();
}, 0);
var options = {
url: function(phrase) {
return '/ajax/employees/get_handworkers_by_name/';
},
minCharNumber: 3,
ajaxSettings: {
dataType: "json",
method: "POST",
data: { dataType: "json" }
},
preparePostData: function(data)
{ data.employeename = $("#empList").val();
return data;
},
getValue: function(element) {
return '['+element.rcp+'] '+element.nazwisko+' '+element.imie;
},
requestDelay: 400,
list: {
maxNumberOfElements: 1000,
onChooseEvent: function() {
sel_prac_rcp = parseInt($("#empList").getSelectedItemData().rcp);
sel_prac_id = parseInt($("#empList").getSelectedItemData().id);
$("#empList").blur();
}
}
};
$("#empList").easyAutocomplete(options);
}, //end onOpen
}).then(function(val){
console.log(val);
});
}
我看着修改easyautocomplete插件,發現這個(約1240線):
$container.on("mousedown", function(e) {
if (!$wrap.is(e.target) // if the target of the click isn't the container...
&& ($wrap.has(e.target).length === 0) // ... nor a descendant of the container
&& (e.target !== $('html').get(0))) // nor the scrollbar
{
//console.log('slog0');
//console.log('slog:'+toolbarClose());
}
//console.log('slog2');
e.stopImmediatePropagation();
e.preventDefault();
e.stopPropagation();
//if (jQuery.browser.msie) {
e.originalEvent.keyCode = 0;
e.originalEvent.cancelBubble = true;
e.originalEvent.returnValue = false;
//}
});
這個片段沒有工作,但是玩。
dissapearing scrollbar issue - animated gif