gpt4 book ai didi

Cakephp $this->布局= 'ajax'

转载 作者:行者123 更新时间:2023-12-01 00:16:02 25 4
gpt4 key购买 nike

当我在 Controller 中声明 $this->layout = 'ajax' 时,我的 css 似乎不起作用。

在我的view1.ctp中,我使用jquery创建了一个对话框。内容将通过 jquery.ajax() 从 view2.ctp 获取。我创建了 html 类、id 和所有类似于 view1.ctp 的内容。

我收到的内容没问题。问题是我在 view2.ctp 中声明的 id 和类不起作用。简而言之,我得到一个空的对话框设计。

知道如何解决这个问题吗?先感谢您。干杯!

在我看来1.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>

最佳答案

AJAX 布局是一个简单的空白文件,仅包含您输出的 HTML(或其他内容)片段。它不包含任何样式表,因为样式信息应来自您要插入内容的页面。在调用页面中定义 ID 和类的样式将解决您的问题。

关于Cakephp $this->布局= 'ajax',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7845763/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com