0
如何將數據從我的表格傳遞到彈出窗口。 這就是我在我的表做到了: 我使用的控制器和模型如何將數據從表格數據傳遞到彈出模式(使用Yii Framework)
<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>
此代碼只在一個文件中。 即時創建的頁面就像。我有一張消息表。然後查看消息是點擊它,彈出窗口會出現。
任何見解?
你的幫助是非常appreaciated。
'body','show' are id's? – sftdev
不,'body'就是html body標籤 - 你將你的模態添加到文檔的末尾。而'.modal(「show」)'是來自twitter-bootstrap,我看到了那個模態體類,並且認爲你將它用於模態。只需使用'.show()'或類似的代碼。 – Eternal1