Ajax 请求未拉出 jQuery 对话框窗口
Ajax request not pulling up jQuery dialog window
请查看此jsFiddle...
这是一个 jQuery UI 对话框,利用 ajax 请求来提取内容。我似乎无法弄清楚出了什么问题,但是除了空白对话框之外,什么都没有弹出。
.HTML。。。
<div id="#griffin"></div>
<ul>
<li>
<a href="ajax/ajax-bj.html" class="griffin-style all-about-bj" id="all-about-bj"></a>
</li>
</ul>
哗啦��
$(function() {
$("#griffin").dialog({
autoOpen: true,
modal: true,
width: 950,
height: 'auto',
show: 'fade',
hide: 'fade',
position: {my: "center top", at:"center top", of: window },
buttons: {
"I have Read and Understand": function() {
$(this).dialog("close");
}
}
});
$(".griffin-style").on("click", function(e) {
e.preventDefault();
$("#griffin").html("");
$("#griffin").dialog("option", "title", "Loading...").dialog("open");
$("#griffin").load(this.href, function() {
$(this).dialog("option", "title", $(this).find("h1").text());
$(this).find("h1").remove();
});
});
});
思潮?
您必须在buttons
参数下给出命令。
http://jsfiddle.net/aEwUF/4/
$(function() {
$( "#griffin" ).dialog({
resizable: false,
height:150,
modal: true,
buttons: {
"I have read and understand the terms": function() {
$( this ).dialog( "close" );
$("p").html("You have accepted the terms");
//write ajax requests in here..
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
需要添加一个jQuery UI对话框打开函数
http://api.jqueryui.com/dialog/#method-open
您必须在本地或在同一台服务器上运行它,因为JSFIDDLE由于同源策略而无法拉取您的外部文件
http://jsfiddle.net/aEwUF/7/
$(function() {
$("#griffin").dialog({
autoOpen: true,
modal: true,
width: 950,
height: 'auto',
show: 'fade',
hide: 'fade',
position: {my: "center top", at:"center top", of: window },
buttons: {
"I have Read and Understand": function() {
$(this).dialog("close");
}
},
// add this
open:function(event,ui){
$("#griffin").html("");
$("#griffin").load($(".griffin-style").attr("href"), function() {
$("#griffin").dialog("option", "title", $(this).find("h1").text());
$(".griffin-style").find("h1").remove();
});
}
});
$(".griffin-style").on("click", function(e) {
e.preventDefault();
$("#griffin").html("");
$("#griffin").dialog("option", "title", "Loading...").dialog("open");
$("#griffin").load(this.href, function() {
$("#griffin").dialog("option", "title", $(this).find("h1").text());
$(this).find("h1").remove();
});
});
});
相关文章:
- 使用jquery对话框中的箭头键
- 获取打开jquery对话框的button的id
- 我怎么能让jQuery对话框表现得像Javascript警报
- 无法在其他调用上设置jQuery对话框选项
- 如何在jQuery对话框标题栏中添加额外的按钮
- 从jquery对话框恢复原始数据,脚本不起作用
- Jquery对话框('打开')不工作
- 通过Rails中的自定义Jquery对话框处理链接的确认
- 阻止Jquery对话框内容的CSS应用于主窗口
- jquery对话框内容仅针对第一个请求进行对齐
- 在鼠标悬停时保持 JQuery 对话框打开
- 带有 iframe 的 jquery 对话框
- 单击函数生成的 jQuery 对话框中的元素
- 在jquery对话框中加载html页面
- JQuery对话框中的Bootstrap Pills
- JQUERY对话框未捕获错误:初始化之前无法调用对话框上的方法
- Jquery对话框的大小调整只发生在它的第一次's已打开
- 打开对话框后,JQuery对话框的条件调整大小为内容高度
- jquery对话框会记住以前的输入
- Jquery.对话框未从表中的图像输入打开