Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从iframe在主窗口中打开Jquery对话框_Jquery_Jquery Ui_Jquery Ui Dialog - Fatal编程技术网

从iframe在主窗口中打开Jquery对话框

从iframe在主窗口中打开Jquery对话框,jquery,jquery-ui,jquery-ui-dialog,Jquery,Jquery Ui,Jquery Ui Dialog,我已经试了一整天了 我在iframe中有一个表单,其中包含用于表单验证的jquery验证。我只希望当数据无效时,jquery对话框出现在主页面上,出现在top.document中 这是我在iframe上的代码: $("#dialog-message", top.document).dialog({ modal: true,

我已经试了一整天了

我在iframe中有一个表单,其中包含用于表单验证的jquery验证。我只希望当数据无效时,jquery对话框出现在主页面上,出现在top.document中

这是我在iframe上的代码:

$("#dialog-message", top.document).dialog({                                                                      
             modal: true,
             autoOpen: false,
             buttons: { Ok: function() {
                 $(this).dialog('close');
               }
             }
          });
这是一段应该激活对话框的代码:

$("#search-form").validate({ 

        rules: { datapicker: {required: true,dateDE: true}},
        debug: true,
        messages: {
         datapicker: {
            required: "És necessari introduïr una data",  
            date: "S'ha d'afegir una data correcte: dd/mm/aaaa"
         }
        },
        errorPlacement: function(error, element) {
                error.prependTo($('#dialog-message', top.document));
        },
        errorLabelContainer: $("#dialog-message ul", top.document),
        showErrors: function () {
            $('#dialog-message',top.document).dialog('open');
            this.defaultShowErrors();
        }
});
所以…这不起作用而且。。。如果我试试这个说明,一切都很好

$("#dialog-message", top.document).css(...) //works fine!
我想选择器$-top.document和对话框功能可能有问题。。。或者可能无法对不同帧中的div使用dialog()

救命啊D


提前感谢

让iframe中的代码引用父对象,并调用父对象的JavaScript函数,如下所示:

// in iframe code:
parent.doSearchFormValidate();

// parent page has definition for doSearchFormValidate().
function doSearchFormValidate() {
  $("#search-form").validate({ 
  ...
  });
}

@webarto,你的评论毫无意义-为什么jQuery在使用iFrame时不适用??。。。我不小心把评论投了赞成票。。。呃,白痴,没有问题了,法官大人。