【发布时间】:2018-08-08 07:28:55
【问题描述】:
我正在尝试使用插件插入 JQuery 弹出窗口。虽然,它工作正常,但每当弹出窗口显示时,它会覆盖整个屏幕宽度。高度很好,但宽度覆盖了整个屏幕。 我尝试使用插件文档中给出的宽度属性,但同样不起作用,而其余属性按预期工作。
以下是示例代码。
function shw(){
$.confirm({
boxWidth: '30%',
animation: 'Rotate',
title: 'Prompt!',
content: '' +
'<form action="" class="formName">' +
'<div class="form-group">' +
'<label>Enter something here</label>' +
'<input type="text" placeholder="Your name" class="name form-control" required />' +
'</div>' +
'</form>',
buttons: {
formSubmit: {
text: 'Submit',
btnClass: 'btn-blue',
action: function () {
var name = this.$content.find('.name').val();
if(!name){
$.alert('provide a valid name');
return false;
}
$.alert('Your name is ' + name);
}
},
cancel: function () {
//close
},
},
onContentReady: function () {
// bind to events
var jc = this;
this.$content.find('form').on('submit', function (e) {
// if the user submits the form by pressing enter in the field.
e.preventDefault();
jc.$$formSubmit.trigger('click'); // reference the button and click it
});
}
});
}
这里方法 shw() 在按钮单击事件上被调用。
【问题讨论】:
-
请编辑您的问题以包含您的代码。见minimal reproducible example。
-
已编辑问题并添加代码。
-
根据插件文档,属性'boxwidth'用于设置弹出框的大小。在这里它不起作用。是否需要任何浏览器更改或类似操作?
-
文档说“useBootstrap 必须设置为 false 才能使用此功能”(
boxWidth) - 你这样做了吗? -
我已将此添加为答案。
标签: jquery popupwindow