【发布时间】:2015-10-15 12:08:24
【问题描述】:
我正在通过 ajax 调用将一些 html 加载到 div 中。在此 html 内容中,单击时会打开一个 jquery 模式。 在第一次单击时,模态会按应有的方式打开,但在随后的单击中,模态将不会打开并在控制台中出现此错误:
Uncaught TypeError: $(...).dialog is not a function
这里是通过 ajax 调用生成的 html,点击它会打开模式:
<div class="edit" rel="630000311">630000311</div>
这是与编辑类相关的 CSS:
.edit {
cursor: pointer;
color: blue;
font-size: 16px;
padding-left:5px;
text-decoration: underline;
}
.ui-widget-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #000;
opacity: 0.7;
filter: alpha(opacity=50);
}
这是我的 jquery
$(document).ready(function(){
$('body').on('click','.edit', function(){
var myDialogX = $(this).position().left - $(this).outerWidth();
var myDialogY = $(this).position().top - ( $(document).scrollTop() + $('.ui-dialog').outerHeight() );
$("#viewDialog").dialog({
width: 1140,
modal: true,
position: { my: 'top', at: 'top+150' },
});
var partID = $(this).attr('rel');
$.ajax({
async: false,
type: 'GET',
url: "parthistory.php",
data: {
"partID" : partID
},
success: function (data) {
$("#viewDialog").html(data);
}
});
});
});
我已尝试添加 $(document).trigger('ready');进入成功,但这无济于事
注意这是我正在加载的 jquery:
code.jquery.com/jquery-1.11.1.min.js"
code.jquery.com/ui/1.11.1/jquery-ui.min.js"
code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css"
【问题讨论】:
-
您应该做的第一件事是为“完成”和“错误”添加处理程序。这会让你知道是否有与之相关的 js 错误以及问题是什么。
标签: javascript jquery html css ajax