简体   繁体   English

嵌入下拉列表的JQuery Modal对话框

[英]JQuery Modal Dialog with drop-down list embedded

I am kind of new to JavaScript but I have a requirement where I need a modal dialog to appear in the middle of the screen and also have a drop down list inside of it. 我是JavaScript的新手,但我有一个要求,我需要一个模式对话框出现在屏幕中间,并在其中有一个下拉列表。 Is there a simple way to do this? 有没有简单的方法可以做到这一点? I haven't been able to find any examples online or on SO. 我无法在线或在SO上找到任何示例。

Here is what I have: 这是我所拥有的:

function showExportDialog() {
    console.log("In requestPanel.js ==> showExportDialog()");

    //initialize and open the dialog
    var $dialog = $('<div></div>').dialog({
        title:   'Export Dialog',
        modal: true,   //dims screen to bring dialog to the front
        buttons: {
            'Export As CSV': function() {
                exportAsCSV();
            },
            'Export As Tab Delimited': function() {
                exportAsTabDelimited();
            },
            'Export As Plain Text': function() {
                exportAsPlainText();
            }
        }
    });
}

When this function is called a modal dialog appears with three buttons that look like this: 调用此函数时,将出现一个模态对话框,其中包含三个如下所示的按钮:

图片

I am hoping for something like this: 我希望这样的事情:

在此处输入图片说明

Any help would be appreciated. 任何帮助,将不胜感激。

This is definitely possible. 这绝对是可能的。 Just put the element markup within the "" like this: 只需将元素标记放在“”中,如下所示:

var $dialog = $('<div><select><option value="item1">item1</option></select></div>').dialog({

But what I would recommend is building the dialog contents in your page somewhere, starting them off hidden (css of 'display:none') and then call the .dialog method on them somewhere else. 但是我建议的是在页面的某处构建对话框内容,将它们从隐藏状态(css为“ display:none”)开始,然后在其他位置对其调用.dialog方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM