大佬教程收集整理的这篇文章主要介绍了jQuery模式对话框拳击没有从iFrame关闭,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
div id="structureDialog" title="Add Structure"
当用户单击父级上的元素时,我会打开对话框:
// bind an onclick event onto tiles to display the modal dialogue window $(".stationTile").bind('click',function () { var src = "<iframe src="myurl" />"; var LOCATIOnID = 1; $("#structureDialog").attr("LOCATIOnID",LOCATIOnID); $("#structureDialog").html(src); //iframe $("#structureDialog").dialog({ modal: true,}); });
$(".userOption").bind('click',function () { $.ajax({ async: false,type: "POST",url: "/NewStructure.aspx/Build",data: "{}",contentType: "application/json; charset=utf-8",dataType: "json",success: buildsuccess }); }); function buildsuccess(res,dest) { $("body",window.parent.document).attr("style","BACkground-color:yellow;"); $("#structureDialog","BACkground-color:red;"); $("#structureDialog",window.parent.document).dialog('close'); }
在我的函数buildsuccess中,我能够成功将对话框更改为红色.但是,关闭功能不会关闭我的对话框.从我到目前为止看到的大多数例子来看,这段代码应该可以正常工作,所以我很难过.
调用$(“#structureDialog”,window.parent.document).dialog(‘close’);使用jquery的本地实例搜索父级的DOM,因此由于没有在那里初始化对话框,所以不能在那里关闭它.
解决方案是通过重新排列术语来引用父项的jquery实例,如下所示:
父$( “#structureDialog”)对话框( ‘亲密’).
这首先将上下文指向父对象,然后使用父对象的jquery实例查找对话框并将其关闭.
感谢Chrismarx1在这篇文章中向我指出了这个解决方案:
http://forum.jquery.com/topic/trigger-from-iframe-to-parent-window
以上是大佬教程为你收集整理的jQuery模式对话框拳击没有从iFrame关闭全部内容,希望文章能够帮你解决jQuery模式对话框拳击没有从iFrame关闭所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。