【问题标题】:JQuery modal dialog not rendering properlyJQuery 模态对话框未正确呈现
【发布时间】:2011-11-14 00:11:27
【问题描述】:

我在我的 ruby​​ on rails 应用程序中使用 jQuery 模式对话框。这是我的代码:

        var html = '';
        html += '<div id="dialog-form">';
        html += 'This is a test.';
        html += '<button id="form-close" class="close-button" type="button" onclick="$(\'#dialog-form\').dialog(\'close\');">Close</button>';
        html += '</div>';

        var dialog_form = $(html).dialog({
            autoOpen: false,
            width: 600,
            height: 640,
            modal: true,
            open: function() {
                $(".ui-dialog-titlebar").hide();
            },
            close: function(event, ui) {
                $('#dialog-form').remove();
            }
        });
        dialog_form.dialog('open');

我在另一个应用程序中使用了相同的代码,它运行良好。

在我当前的应用程序中,此脚本不是呈现模式对话框,而是呈现透明对话框窗口。文本和按钮正确呈现。但是,对话框是透明的,而不是模态的。

我确定我已经包含了 jquery.js 和 jquery-ui.js。

我不知道我在做什么有什么问题。请帮忙。

谢谢。

【问题讨论】:

  • 好像没有在页面中添加jquery-ui主题css文件。
  • 谢谢,这就是我所缺少的。墨菲定律的例证!

标签: jquery ruby-on-rails jquery-ui


【解决方案1】:

添加jquery css、js文件的引用。还要检查对话框的类名是否正确。您需要在主 div 中添加更多 div(确切的代码在 jqueryui.com 的 jquery 代码的索引页中)

【讨论】:

    猜你喜欢
    • 2012-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-14
    • 1970-01-01
    • 1970-01-01
    • 2011-10-17
    • 1970-01-01
    相关资源
    最近更新 更多