我刚刚开始使用 Yii 框架。单击时,我很难将列表数据传递给模式。我已经在使用 AJAX。我的模式与我的列表在同一个视图中。所以我的代码基本上看起来像这样..
这是我的看法:
<div id="view-data" class="modal viewdata-modal fade hide" data-backdrop="true">
<!-- the full data from clicked list -->
</div> 
.
.
.
<div>
<!--table--list of something-->
    <tr class="odd">
        <td class=" "><a onclick="checkData('<?php echo $inbox_list_data['id']; ?>')" data-toggle="modal" data-target="#view-mail" ><?php $list_data['title'];?></td>                                               else echo $msg; ?></a></td>
        <td class=" "><?php $date = $list_data['date_updated']; echo date('Y / m / d',strtotime($date));?></td>
    </tr>
</div> 
然后这是我的 JS:
    function checkData(id) {
        $.ajax({
            type : 'POST',
            url : "/link/data/view",
            data : {'id' : id},
        });
    }
然后在我的控制器中:
    public function actionIndex()
    {
        //getting list from db then render
    }
    public function actionView()
    {
        $this->initPage();
        Helper_Site::supportMessageJS();
        if(isset($_POST['id']))
        {
            $id = $_POST['id'];
            //use the id for getting the data then ...??
        }
        //I cannot render since i'm passing it to modal and i dont have to refresh the page right?
        $this->renderPartial('index', array('data1'=>$data1, 'data2'=>$data2, true, false);
    }
那么我怎样才能将我的数据传回我的视图呢?但我也不确定我的 JS ......
非常感谢任何想法。谢谢