UI对话框显示在页面上而不是弹出窗口

UI对话框显示在页面上而不是弹出窗口

本文介绍了jQuery UI对话框显示在页面上而不是弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jqueryUI对话框弹出窗口,该对话框显示在页面上...并在需要时弹出.一些奇怪的功能. div内的所有内容都将显示在页面上,但是弹出窗口将起作用,但是div上没有内容.我正在尝试在文档准备好之前创建弹出窗口.这是我的对象正在运行的代码,再次在文档准备好之前.

I have a jqueryUI dialog popup that is showing on the page... and popping up when requested. Some odd functionality. Anything within the div will show on the page, and the popup will work however be without the contents on the div. I am trying to create the popup before the document is ready. Here is the code that my object is running, again before document ready.

    var edit_div=document.createElement('div');
    var me = this;
    $(edit_div).dialog(
        {
            autoOpen: false,
            height: 400,
            width: 600,
            resizable: false,
            modal: true,
            buttons:
            {
                "Submit": function()
                {
                    me.submitForm();
                },
                Cancel: function()
                {
                    $( this ).dialog( "close" );
                }
            },
            close: function()
            {
            },

        });

如果我将对话框创建代码移至一个单独的函数并在文档准备就绪时调用它,则弹出窗口将正常工作,如下所示:

The popup works correctly if I move the dialog creation code to a separate function and call that when the document is ready like so:

$(document).ready(function()
{
   mfg_table.init();
}

以及用于创建对话框的初始化代码

And the init code to create the dialog

   this.init = function()
    {
        //alert('initing');
        var me = this;
        $('#' +this.table_id + this.edit_table_name).dialog(
            {
                autoOpen: false,
                height: 400,
                width: 600,
                resizable: false,
                modal: true,
                buttons:
                {
                    "Submit": function()
                    {
                        me.submitForm();
                    },
                    Cancel: function()
                    {
                        $( this ).dialog( "close" );
                    }
                },
                close: function()
                {
                },

            });
    }

那么为什么我不能在呈现页面之前在DOM对象上创建对话框?

So why can't I create the dialog on the DOM object before rendering of the page?

推荐答案

是否有可能在浏览器加载jquery.js文件之前调用脚本?

Is it possible your script is being called before your jquery.js files are being loaded by the browser?

Document.ready等到页面完全加载后再运行代码.没有它,它将无法正常工作,这意味着在尝试运行脚本之前,没有加载必要的资源.

Document.ready waits until the page is fully loaded before running your code. The fact that it isn't working correctly without it, implies that the necessary resources aren't being loaded before you try to run your script.

您可能希望尝试将内联脚本移到html文件的末尾,尤其是在引用了所有.js和插件文件之后.

You may want to try to move your inline script to the very end of your html file, particularly after all your .js and plugin files have been referenced.

我希望我可以更具体一些,但是如果没有更多的代码或实际示例,很难知道发生了什么.

I wish I could be more specific, but it's hard to see whats going on without more of the code or a live example.

这篇关于jQuery UI对话框显示在页面上而不是弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 23:13