0

任何人都可以帮忙,...我有一个评论页面,其中包含我想用 ajax 调用对话框的报告/垃圾邮件链接,...我该怎么做,..?在此先感谢,...这是我的代码:

<script>

$(function() {
 $('#photo_comments_opener_<?php echo $photo_comment['PhotoComment']['id'] ?>').dialog({
 autoOpen: false,
 width: 500,
 modal: true,
 title: 'Report Photo Comment',

    open: function ()
    {
        $.ajax(function(){
            url: "<?php echo $html->url("/report/photo_comment/" . $photo_comment['PhotoComment']['id']) ?>",
            data: data, 
            type: "post",
            sucess:function(msg){
                $('#photo_comments_opener_<?php echo $photo_comment['PhotoComment']['id'] ?>').html(msg)
            }
        });
   }       

});

  });
</script> 

这是链接:

<?php echo $html->link(ucfirst(__('report', true)), 'javascript:void(0)', array('id' => "photo_comments_opener_".$photo_comment['PhotoComment']['id'], 'class' => 'report')) ?>

感谢您的回复 Chintana,...但是我无法成功,...我有一个打开对话框的代码,...但我无法将 ajax 调用放入:

<script>
$(function() {
$( "#photo_comments_dialog_<?php echo $photo_comment['PhotoComment']['id'] ?>" ).dialog({
autoOpen: false,
width: 500,
modal: true,
title: 'Report Photo Comment'

});

$( "#photo_comments_opener_<?php echo $photo_comment['PhotoComment']['id'] ?>" ).click(function() {
  $( "#photo_comments_dialog_<?php echo $photo_comment['PhotoComment']['id'] ?>" ).dialog( "open" );
});

});
</script>

这是链接:

<?php echo $html->link(ucfirst(__('report', true)), 'javascript:void(0)', array('id' => "photo_comments_opener_".$photo_comment['PhotoComment']['id'], 'class' => 'report')) ?>

这是 ID div:

<div id="photo_comments_dialog_<?php echo $photo_comment['PhotoComment']['id'] ?>"></div>

请帮我完成这个,...提前谢谢

4

1 回答 1

0

我的 PHP 不是很好,所以我会尝试围绕 javascript/jquery 构建我的想法

我假设您通过单击按钮或链接来调用显示对话框部分。为什么不像您所做的那样使用 $.ajax 的成功回调更进一步,并在其中显示对话框

类似的东西

function displayCommentDialog(){
    $.ajax(function(){
        url: "<?php echo $html->url("/report/photo_comment/" . $photo_comment['PhotoComment']['id']) ?>",
        data: data, 
        type: "post",
        sucess:function(msg){
            $('#photo_comments_opener_<?php echo $photo_comment['PhotoComment']['id'] ?>').html(msg);

            var d = $('#photo_comments_opener_<?php echo $photo_comment['PhotoComment']['id'] ?>').dialog(
                {
                    // all your dialog options
                });

                d.dialog("open");
        }
    });
}
于 2013-03-12T04:30:10.547 回答