I’ve been working in CakePHP and I got the following problem.
I have a admin page (AdminsController) with 1 view and 1 method, Index.
The index view includes hard-coded links to other controllers and views.
I did assign a class to all those links to load a DIV over the admin content with the content of the view in it. Via this script:
$(".cmsPage").click(function() {
var url = $(this).attr("href");
$.ajax({
url: url,
success: function(data){
$("#admin_wrapper", "#admin_close", "#admin_content").fadeIn('slow');
$("#admin_content").html(data);
}
});
return false;
});
Now in one of those views of the pages controller, pages/overview I made an ajax call to an other method in the same controller, update_menu. This method has a view also. This is what currently have in my controller/method.
public function update_menu(){
$this->layout = '';
foreach($this->request->data as $menu){
//$this->layout = 'ajax';
foreach($menu as $id => $submenu){
$saveData = array('id' => $id, 'submenu' => $submenu);
$this->Page->save($saveData);
$this->render('update_menu','ajax');
}
}
}
The Admin controller has a Admin layout so does the overview.
This is what happens when I try to get the data from update_menu. (inside $(document).ready(function(){}); )
$("#save_page").click(function(){
toArray();
return false;
});
function toArray() (outside $(document).ready(function(){});)
function toArray()
{
var serialized = $('ol.sortable').nestedSortable('serialize');
$.ajax({
type: 'POST',
url: 'update_menu',
data: serialized,
success: function(data){
$("#result").html('De pagina\'s zijn opgeslagen!');
}
});
}
What I get back in the console is the whole render of admins/index. view& layout.
What do I need to do to get the view result instead of the admins/index.
For the information, I’d use http://mjsarfatti.com/sandbox/nestedSortable/forum/categories/releases.
Greetings,
Harm.
Since this is ajax call for this, you dont need to load any layout in your action
try this.