jQuery弹出窗口返回值给父级

jQuery弹出窗口返回值给父级

本文介绍了jQuery弹出窗口返回值给父级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 jQuery 完成以下操作:单击子窗口中的链接时,打开一个弹出窗口,该窗口返回一个值给父窗口,关闭子窗口,然后让父窗口自动提交基于返回的值?

How can I accomplish the following using jQuery: Open a popup window that returns a value to the parent window when a link in the child window is clicked, close the child window, and then have the parent automatically submit a form based on the value returned?

我意识到 jQuery Dialog 是一种流行的解决方案,但我需要一个弹出窗口,因为窗口的内容需要可导航,并且我想避免在 jQuery Dialog 中使用 iframe.

I realize that the jQuery Dialog is a popular solution, but I require a popup window because the window's contents need to be navigable, and I want to avoid using an iframe in the jQuery Dialog.

弹出窗口将用于收集多个值,最终以分隔字符串的形式返回给父级,但此数据收集需要在提交父级窗口的表单之前进行.如果实体选择器"有标准设计模式,那就是它.

The popup window is going to be used to collect more than one value, ultimately to be returned as a delimited string to the parent, but this data collection needs to occur prior to the submission of the parent window's form. If there were a standard design pattern for an "Entity Picker", this would be it.

这需要在 IE8、FF3.6、Safari 4 和 Chrome 5 中运行.

This needs to work in IE8, FF3.6, Safari 4, and Chrome 5.

谢谢,标记

推荐答案

这是我的解决方案:

var parent = $(parent.document.body);
$(parent).find('input#valStore').val(theVal);
$(parent).find('form#myForm').submit();
window.close();

这篇关于jQuery弹出窗口返回值给父级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 13:43