Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9148013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:09:19+00:00 2026-06-17T11:09:19+00:00

I have currently migrated my cakePHP application from 1.3 to 2.2.4. It manages tasks

  • 0

I have currently migrated my cakePHP application from 1.3 to 2.2.4. It manages tasks with tree behavoir. I use jQuery for the ajax.

When I click on a task, an ajax request is fired and the response (the subtasks) update the content of the task div. That works fine for the first level. But the 2nd level does not have any javascript code beeing generated, so the click leads to a blank page, only showing the plain ajax response (only the subtasks of the 2nd level).

How can I tell cakePHP to generate further Javascript code to update the the div? HTML ID’s are beeing generated correctly.

Any help would be great!

function expand in TasksController.php:

function expand($id = NULL, $check = 1) {
/*
    get details of given task ID
*/
// if not expanded yet
if ((!$this->Session->check('Task.expand.'.$id))||($check==0)) {
    // set session variable to "expanded"
    $this->Session->write('Task.expand.'.$id, 1);

    // get task details
    $zahlen = array(1 => 'eins', 2 => 'zwei', 3 => 'drei', 4 => 'vier', 5 => 'fünf');
    $this->set('commentlimit', $zahlen[$this->Session->read('Profile.commentcount')]);
    $this->Task->Behaviors->attach('Containable');
    $this->Task->recursive = -1;
    $this->Task->contain(array('Assignee' => array('fields' => array('id', 'name', 'firstname')), 'Tasktype', 'Comment' => array('fields' => 'text', 'limit' => $this->Session->read('Profile.commentcount'), 'order' => 'lft DESC', 'user_id', 'User' => array('fields' => array('name', 'firstname')))));
    $this->set('task', $this->Task->find('first', array('conditions' => array('Task.id' => $id, 'Task.user_id' => $this->Session->read('UserId')))));
}
// if yet expanded, collapse / unload
else {
    $this->Session->delete('Task.expand.'.$id);
    $this->redirect(array('controller' => 'tasks', 'action' => 'collapse'));
}
    //  pr ($this->Session->read('Task'));

    $this->render('expand', 'ajax'); 

    }

And this is my taskelement, which is beeing requested and filled for each task:

<div class="task <?php echo $thisclass; ?>">
    <?php
    echo $this->Js->link($task['Task']['name'], array( 'controller' => 'tasks', 'action' => 'expand', $task['Task']['id'] ), array( 'update' => '#details'.$task['Task']['id'] ));
    echo " <span>(".$this->requestAction('/tasks/countAllChildren/'.$task['Task']['id'])." Unterpunkte, davon ";
    echo $this->requestAction('/tasks/countDirectChildren/'.$task['Task']['id'])." direkt)</span>";
    echo " <span>(".$this->requestAction('/tasks/countAllDoneChildren/'.$task['Task']['id'].'/'.$task['Task']['lft'].'/'.$task['Task']['rght'])." erledigt)</span>";
    ?>
<div id="details<?php echo $task['Task']['id']; ?>">
    <?php
        echo $this->requestAction('/tasks/is_expanded/'.$task['Task']['id']);
    ?>
</div>
    </div>

The relevant part of expand.ctp look like this:

    <?php
    $children = $this->requestAction('/tasks/getChildren/'.$task['Task']['id']);
    if ($children) {
    ?>
<p><h4>Unteraufgaben:</h4>
<?php
echo $this->Html->link('Neu',"/tasks/add/".$task['Task']['id'], array('class'=>'button'));
foreach ($children as $child) {
    $this->set('task', $child);
// todo: das hier eleganter machen, ohne zusätzliche Abfragen
    $this->set('level', $this->requestAction('/tasks/getDepth/'.$task['Task']['id']));
    echo "<tr>".$this->element('taskmesh')."</tr>";
}
    }
    else {
?>
<p><h4>Keine Unteraufgaben</h4>
<?php
echo $this->Html->link('Neu',"/tasks/add/".$task['Task']['id'], array('class'=>'button'));
    }
?>
</p>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:09:22+00:00Added an answer on June 17, 2026 at 11:09 am

    When I asked another CakePHP guy, he told me to use the JavaScript buffer and linked to it in the CakeBook: http://book.cakephp.org/2.0/en/core-libraries/helpers/js.html

    So the answer to my question is:

    Add the following code the bottom of the view of the requested ajax action:

    echo $this->Js->writeBuffer(); // Write cached scripts
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently having a strange issue with an application migrated from rails 2.3.8
We have a web application that uses dropbox as file storage. We have currently
I have migrated my app to use the new GCM push system. It works
I'm currently working on a fairly large project that has been migrated from Ant
I have an application in asp.net2.0 with C#. I have migrated my application in
I currently have a Grails application I'm evaluating to port to Google App Engine
Currently I have big application with huge amount of initial data. Basicly, I have
I have a team of 3 developers including myself and currently we use VSS.
I am currently migrating our build process from Eclipse/Ant to Maven/M2Eclipse/Artifactory. I have a
I am attempting to migrate from XDV to Diazo. Currently I have a theme

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.