1

我一直在尝试在我的页面中添加一个模式对话框,该对话框在单击超链接时显示,并从另一个 URL 获取内容。问题是,我找不到使它成为模态的方法,因为它仍然可以与背景页面交互,我不希望那样。

这是我正在使用的代码,

HTML

<html>

  <head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css" type="text/css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js"></script>
  </head>

  <body>
    <a class="ajax" href="login.html">Open as dialog</a>
  </body>

</html>

CSS

.loading {
  background: url(/img/spinner.gif) center no-repeat;
}

jQuery

$(function() {
  var ajaxDialog = $('<div id="ajax-dialog" style="display:hidden"></div>').appendTo('body');
  ajaxDialog.dialog({
    autoOpen: false
  });
  $('a.ajax').live('click', function() {
    ajaxDialog.load(this.href);
    ajaxDialog.dialog("open");
    return false;
  });
});

请,如果有人可以帮助使其成为模态。提前致谢。

4

1 回答 1

1

您是否尝试过使用 ajaxDialog.dialog("modal","true"); ?

http://api.jqueryui.com/dialog/#option-modal

于 2013-10-31T15:57:47.727 回答