首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在编码器中获得fancybox的返回值

问如何在编码器中获得fancybox的返回值
EN

Stack Overflow用户
提问于 2014-12-23 12:21:49
回答 2查看 1.6K关注 0票数 0

我使用的是Fancybox V1.3.4。我在将表单提交的值返回到父页面时遇到了问题。我不会从当前屏幕(子帧)中获得值。

添加页面

代码语言:javascript
复制
<div id ="app_fee_list">
     Fee Split/ Payment Details box 
<a id ="new_app_fee" href="<?php echo base_url('updateappraiserpayment/0')?>" ><i style="margin-left:15px;" class="fa fa-plus-square"></i></a>
                     <?php $this->load->view('andersion/appraiser/appraiserfeetemplate'); ?>
                </div>

这里的fancybox代码如下

代码语言:javascript
复制
<script>  
    jQuery(document).ready(function(){
        jQuery('#new_app_fee').live('click', function(){ 
            jQuery(this).fancybox({
            'width'             : '60%',
            'height'            : '90%',
            'autoScale'         : false,
            'transitionIn'      : 'none',
            'transitionOut'     : 'none',
            'type'              : 'iframe',
            'onCleanup': function(){
                feeid = jQuery('#appfeeform').contents().find("#app_fee_id").val();
                alert(feeid);return false; // Here value returns Undefined.
               // If the app_fee_id filed is in Add page it will returns.But this field is not in the ADD page. It is in the SUCCESS page.
            },
            'onClosed': function() {
                location.reload();
            }

        });
    }).trigger('click');
    });
    </script> 

它触发到updateappraiserpayment页面。提交此表单后,它将重定向到成功页面。

成功页面

代码语言:javascript
复制
<form name = 'appfee1' id='appfeeform' action="<?php echo base_url('updateappraiserpayment/'.$user_id)?>" method='post'>
<div class="col-sm-12">

          <section class="panel">
            <div class="success">Appraiser fee information has been added successfully</div>
             <input type="hidden" name='appraiser_fee_id' id ="app_fee_id" value="3">   
             </form>
            <?php echo $appraiser_fee_id;exit; // Here i get the Inserted Id Value?>

          </section>
        </div>

成功消息还将显示在iframe.After中,关闭我需要的iframe,以获得插入值的值到父页面。我也试过这样

代码语言:javascript
复制
$(".fancybox-iframe").contents().find("#app_fee_id").val();

但我无法得到结果。请给我一些解决这个问题的建议。提前感谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-12-23 14:26:35

您正在尝试从iframe页面获取一个值到父页,并在父页上运行js函数。

我认为要获得从iframe到父级的值,需要在iframe页面中编写js代码。

因此,若要从成功页到父页获取隐藏字段“app_fee_id”的值(假设在加载页时填充“app_fee_id”值),请在成功页上编写以下js函数,

代码语言:javascript
复制
jQuery(document).ready(function($) {
    parent.$("#parent_app_fee_id").val($("#app_fee_id").val());
});

在父页中添加以下代码,

代码语言:javascript
复制
<input type='hidden' id='parent_app_fee_id' value=''>

并更新“onCleanup”函数的下面一行,

代码语言:javascript
复制
feeid = jQuery('#parent_app_fee_id').val();
票数 2
EN

Stack Overflow用户

发布于 2014-12-23 12:40:36

parent.window.document

示例:

代码语言:javascript
复制
parent.window.document.getElementById("parentPagetagId").value = 3;//set value for input parent page
parent.window.document.getElementById("fancybox-wrap").style.display = 'none';//hidden fancybox

我认为它将出现在这样的jQuery中(但没有检查):

代码语言:javascript
复制
$("#parentPagetagId",parent.window.document).val(3);
$("#fancybox-wrap",parent.window.document).hide();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27620282

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档