我试图通过单击列表视图中的链接(单击此处)来弹出一个对话框。弹出框工作正常,但是当我单击任何单击此处链接时,它会显示列表中第一个数据的标题。单击每个数据项的链接时,我想显示相应的标题。索引.php
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'template'=>"{items}\n{pager}",
)); ?>
<script>
$(document).ready(function () {
$("#closebtn").click(function () {
$("#dlg").hide('800', "swing", function () { $("#bkg").fadeOut("500"); });
});
$(".opn").click(function () {
if (document.getElementById('bkg').style.visibility == 'hidden') {
document.getElementById('bkg').style.visibility = '';
$("#bkg").hide();
}
if (document.getElementById('dlg').style.visibility == 'hidden') {
document.getElementById('dlg').style.visibility = '';
$("#dlg").hide();
}
$("#bkg").fadeIn(500, "linear", function () { $("#dlg").show(800, "swing"); });
});
});
</script>
_view.php
<div class="post">
<?php echo $data->title;
echo $data->author;
?>
</div>
<div class="normal">
<p><a href="#" class="opn">Click here</a></p>
</div>
<div class="blockbkg" id="bkg" style="visibility: hidden;">
<div class="cont" id="dlg" style="visibility: hidden;">
<div class="closebtn" title="Close" id="closebtn"></div>
<?php echo $data->title; ?>
</div>
</div>