Javascript Jquery对话框只显示文本消息
我定义了如下对话框:Javascript Jquery对话框只显示文本消息,javascript,jquery,dialog,Javascript,Jquery,Dialog,我定义了如下对话框: <script> $(function () { $('#dialog_error').dialog({ title: 'خطا', autoOpen: false, width: 700, resizable: false, modal: true, show: { effect: 'f
<script>
$(function () {
$('#dialog_error').dialog({
title: 'خطا',
autoOpen: false,
width: 700,
resizable: false,
modal: true,
show: { effect: 'fade', speed: 500 },
hide: { effect: 'fade', speed: 500 },
buttons: {
'بستن': function () { $("#dialog_error").dialog("close"); }
}
});
});
</script>
$dlg.dialog('open');
$dlg.html(data.Message);
警报显示正确,但对话框未打开。
“data.Message”的值显示在屏幕中间其他“div”之后
为什么呢
var $dlg=$('#dialog_error').dialog({
title: 'خطا',
autoOpen: false,
width: 700,
resizable: false,
modal: true,
show: { effect: 'fade', speed: 500 },
hide: { effect: 'fade', speed: 500 },
buttons: {
'بستن': function () {$(this).dialog("close");}
}
});
确保$dlg变量在您想要更改内容的范围内,
然后只需调用.html()
即可,如下所示:
<script>
$(function () {
$('#dialog_error').dialog({
title: 'خطا',
autoOpen: false,
width: 700,
resizable: false,
modal: true,
show: { effect: 'fade', speed: 500 },
hide: { effect: 'fade', speed: 500 },
buttons: {
'بستن': function () { $("#dialog_error").dialog("close"); }
}
});
});
</script>
$dlg.dialog('open');
$dlg.html(data.Message);
第一个问题是在代码中添加“jquery-ui-1.9.2.min.js”。也使用
$(document).ready(function () {}
防止在打开对话框之前生成对话框。是否为对话框添加了适当的
css
文件?控制台中是否有错误可能已打开,但由于缺少css
文件而无法正常显示。这不是css。我可以在其他页面中看到此警报。我的控制台中有此错误:未捕获类型错误:对象[Object Object]没有方法“dialog”