Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery对话-同一页面上的多个_Jquery_Jquery Ui - Fatal编程技术网

Jquery对话-同一页面上的多个

Jquery对话-同一页面上的多个,jquery,jquery-ui,Jquery,Jquery Ui,我试图在一个页面上多次实现jquery对话框——基本上,我希望在用户单击其姓名时显示有关此人的更多信息 我正在用php生成页面 我已经尝试过这样做,并使它部分工作,但我只能使页面上的第一个实例工作。请任何人都给我举个例子,因为UI页面上的那些没有多大帮助,因为当页面打开时它们会自动弹出 我没有发布我的代码,因为我认为这不是正确的方法 Thaks提前。以下是一个有效的例子 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://ww

我试图在一个页面上多次实现jquery对话框——基本上,我希望在用户单击其姓名时显示有关此人的更多信息

我正在用php生成页面

我已经尝试过这样做,并使它部分工作,但我只能使页面上的第一个实例工作。请任何人都给我举个例子,因为UI页面上的那些没有多大帮助,因为当页面打开时它们会自动弹出

我没有发布我的代码,因为我认为这不是正确的方法


Thaks提前。

以下是一个有效的例子

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<!-- Above Doctype should provide S mode in Moz, Safari, Opera, IE8 and A (almost standards) in IE6/7 -->
<head>
  <meta http-equiv="Content-Type" content="application/text+html;utf-8"/>

  <title>Sandbox</title>

  <link rel="stylesheet" href="css/screen.css" type="text/css" media="screen" charset="utf-8" />
  <link rel="stylesheet" href="css/print.css" type="text/css" media="print" charset="utf-8" />
  <link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
<style type="text/css">

</style>

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
    google.load("jquery", "1.3.2");
    google.load("jqueryui", "1.7.0");
</script>
<script type="text/javascript">
google.setOnLoadCallback(function() {

      $(document).ready(function() {
        $('.more-text').toggle();
        $('.more').click(function() {
            $(this).parent().next('p').dialog();
        })


    });
});
</script>
</head>
<body>
    <div id="container">
        <div id="person-1">
        <p>Short text for person one <a href="#" class="more">Show more</a></p>
        <p class="more-text">This is more of the text</p>
        </div>
        <div id="person-2">
        <p>Short text for person two <a href="#" class="more">Show more</a></p>
        <p class="more-text">This is more of the text with a longer description that
        is supposed to go into a popup</p>
        </div>
    </div>
</body>

</html>

沙箱
load(“jquery”,“1.3.2”);
load(“jqueryui”,“1.7.0”);
setOnLoadCallback(函数(){
$(文档).ready(函数(){
$('.more text').toggle();
$('.more')。单击(函数(){
$(this.parent().next('p').dialog();
})
});
});
第一人称短文本

这是更多的文本

第二个人的短文本

这是更多描述较长的文本 应该进入一个弹出窗口


您需要的所有信息都在UI文档页面的底部标有“选项”和“方法”的选项卡上。这些人是你的朋友,他们会告诉你(几乎)小部件可以做的一切。比如说,

<div id="dialog" title="Basic dialog">
    <p>This is the default dialog which is useful for displaying
       information. The dialog window can be moved, resized and
       closed with the 'x' icon.</p>
</div>
...
<a href="" onclick="openDialog('Peter Smith', '<p>Peter Smith likes dirt bike riding, mountain climbing and punk music.</p>'); return false;">Peter Smith</a>
...
<script type="text/javascript">

    $(document).ready( function() {
       $("#dialog").dialog({ autoOpen: false, modal: true });
    });

   function openDialog(title, text) {
        $("#dialog").html(text).dialog('option','title',title).dialog('open');
   }
</script>

这是用于显示的默认对话框
信息。对话框窗口可以移动、调整大小和
用“x”图标关闭

... ... $(文档).ready(函数(){ $(“#dialog”).dialog({autoOpen:false,modal:true}); }); 函数openDialog(标题、文本){ $(“#dialog”).html(text.dialog('option','title',title.dialog('open'); }
感谢您抽出时间来做这些Steerpike。作为一个初学者,它看起来很棒,但是尝试一下,对话框只有在第一次点击时才会弹出,我想我在某个地方读到了关于这个的另一个答案,我现在会搜索,但是有什么想法吗?它只会触发一次,因为当对话框变成弹出窗口时,它会将标记从DOM中拉出。现在我正在工作,没有时间调查这个问题。不过我知道这是可能的,我已经在另一个项目中使用了与我发布的代码类似的代码,完全满足了您的需要。不幸的是,我目前无法访问我编写的代码。事实上,是的,我可以访问-它目前正在运行。你可以在(查看源代码)@Steerpike解决方案仍然有效,并为我解决了这个问题链接现在是Hi Ajw,谢谢你的回答,但是上面缺少的一点是如何为不同的链接选择不同的文本位。据我所知,这将选择id为dialogue的div,并始终打开它,