2012-07-03 17 views
0

我对JavaScript很陌生,但我有一个要求,我需要一个模式对话框出现在屏幕中间,并在其中有一个下拉列表。有没有简单的方法来做到这一点?我无法在网上或在SO上找到任何示例。嵌入式下拉列表的JQuery模态对话框

以下是我有:

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(); 
      } 
     } 
    }); 
} 

当这个函数被调用一个模式对话框会出现三个按钮,看起来像这样:

image

我希望这样的事情:

enter image description here

任何帮助,将不胜感激。

回答

1

这绝对有可能。只要把元素标记中的“”是这样的:

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

但我会建议某处建立在你的页面的对话内容,从它们关闭隐藏(CSS的“显示:无”),然后调用在其他地方的.dialog方法。

+0

谢谢,这工作完美 –

+1

演示:http://www.dstrout.net/pub/dialog.htm –