我如何将数据从我的表传递到弹出窗口。这就是我在我的表中所做的:我使用控制器和模型从我的数据库中填充表
<table class="table table-striped table-checkable" id="demo-dtable-02" aria-describedby="DataTables_Table_0_info">
<thead>
<tr>
<th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Subject: activate to sort column ascending" style="width: 220px;">??</th><th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Date: activate to sort column ascending" style="width: 79px;">??</th>
</tr>
</thead>
<tbody role="alert" aria-live="polite" aria-relevant="all">
<?php
foreach ($my_page_data['text_list']as $text_list_key => $text_list_data){
?>
<tr class="odd">
<td class=" "><a href="#" onclick="viewText(<?php echo $text_list_data['id'] ?>)" data-toggle="modal" data-target="#view-text" ><?php $msg = $text_list_data['msg']; ?></a></td>
<div id="<?php echo $inbox_list_data['id'] ?>" data-content="<?php $msg = $inbox_list_data['message']?>"></div> <!-- i used this as a hidden div for the data to be passed because i dont know other ways -->
<td class=" "><?php $date = $text_list_data['date_updated'];?></td>
</tr>
<?php } ?>
</tbody>
</table>
然后我用一个脚本来传递数据......
<script>
function viewInbox(id){
$('#inbox-message-body').text($('#'+id).attr('data-content'));
}
</script>
然后点击的数据会显示在这里:
<div class="modal-body">
<div class=" . . .">
<div class="..">
<span class="view-label">From:</span> MY OTHER DATA <!--TODO: -->
<br>
<span class="view-label">To:</span> MY DATA<!--TODO: -->
<br>
</div>
</div>
<!--TODO: Message body--> I
<span id="message-body" class="span8"></span>
</div>
此代码仅在一个文件中。我创建的页面就像。我有一个消息表。然后查看消息是单击它,然后会出现一个弹出窗口。
有什么见解吗?
非常感谢您的帮助。