當我在我的控制器中聲明$ this-> layout ='ajax'時,我的css dosnt似乎工作。
在我的view1.ctp中,我創建了一個使用jquery的對話框。內容將通過jquery.ajax()從view2.ctp獲取。我創建了html類,id和所有類似於view1.ctp的。
即時接收的內容沒問題。問題是我在view2.ctp中聲明的id和class不起作用。簡而言之,我即將獲得一個空的對話框設計。
關於如何解決這個問題的任何想法?先謝謝你。乾杯!
在我view1.ctp:
<div id="thisDialog">
<div id="content">
</div>
</div>
<script>
jQuery('.test_box').live('click',function(){
jQuery('#content').empty();
jQuery.ajax({
async:false,
url: '/controller1/view2/'+id //url pointing to my 1controller.php
success:function(data){
jQuery('#content').append(data);
}
});
jQuery('#thisDialog').dialog('open');
});
</script>
這裏是controller1.php
function view2($id)
{
$this->layout = 'ajax';
$query = $this->Model->find('all') //somequery here
}
這裏是view2.ctp
<div class='box'>
<div class='title'>
<h5>Title here</h5>
</div>
<div class='contents'>
<table>
<tr>
<td class='head'></td>
<td class='head'></td>
</tr>
<tr>
<td class='alt'>Field content1 here</td>
<td>Fields content2 here</td>
</tr>
</table>
</div>
</div>
你還可以添加你的default.ctp和ajax。 ctp? – Rifat