请看我的jsfiddle https://jsfiddle.net/fp2vg48z/2/
这是代码:
$('a').click(function(){
$( "#container" ).dialog({
height: 430,
width: 620,
title: 'click hello',
modal: true,
buttons: [
{
text: 'Back',
click: function() {
$( this ).dialog( "close" );
}
}
],
create: function( event, ui ) {
},
close: function( event, ui ) {
}
});
});
$('.justalert').click(function(){
swal({
title: 'hello',
text:'Please enter name',
type:'input',
showCancelButton: true,
closeOnConfirm: false,
inputPlaceholder: "E.g john"
}, function(inputValue){
if (inputValue === false)
return false;
if (inputValue === "") {
swal.showInputError("You need to enter something!");
return false;
}
swal({title: " success " + inputValue+" added!", type:"success", timer:10000 });
});
});
$(document).on('click','.hello',function(){
swal({
title: 'hello',
text:'Please enter name',
type:'input',
showCancelButton: true,
closeOnConfirm: false,
inputPlaceholder: "E.g john"
}, function(inputValue){
if (inputValue === false)
return false;
if (inputValue === "") {
swal.showInputError("You need to enter something!");
return false;
}
swal({title: " success " + inputValue+" added!", type:"success", timer:10000 });
});
});
CSS:
#container{ padding:20px; background:#ccc;display:none;}
.sweet-overlay{z-index:5000;}
.sweet-alert{z-index:5001;}
当在模式顶部触发甜蜜警报时,输入不会获得焦点。我仍然可以选择顶部的文本,但焦点没有发生。我不确定这是否是来自甜蜜警报的东西。
否则输入工作正常。
有什么想法吗?
最佳答案
您可以尝试用空函数覆盖 bootstrap 的 enforceFocus 函数
$.fn.modal.Constructor.prototype.enforceFocus = function() {};
关于jquery - 甜蜜的警报输入不专注于 jquery ui 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31215222/