I know the title isn't that clear, but I didn't know what to put in there. I will explain the situation as best as I can!
When you go to [ourwebsite]/users/ you see on the left side a list of all the users and when you click on one user you can edit the user on the right side. See screenshot: <https://lh3.googleusercontent.com/-AEbTgQxmeF4/T9ieecmdaEI/AAAAAAAAABo/xfyCBvRVDr0/s1600/Schermafbeelding+2012-06-13+om+16.06.30.png> left: user list (view = index.ctp) right: edit user (view = edit.ctp) We did this using ajax, in short our code looks like this: /****** UsersController ******/ class UsersController extends AppController { public $helpers = array('Js' => array('Jquery')); public $components = array('RequestHandler'); public function index() { $this->User->recursive = 0; $this->set('users', $this->paginate()); } public function edit($id = null) { $this->User->id = $id; if (!$this->User->exists()) { throw new NotFoundException(__('Invalid user')); } if ($this->request->is('post') || $this->request->is('put')) { if ($this->User->save($this->request->data)) { //$this->Session->setFlash(__('The user has been saved')); //$this->redirect(array('action' => 'index')); echo "Gebruiker is bewerkt!"; $this->autoRender = false; } else { //$this->Session->setFlash(__('The user could not be saved. Please, try again.')); echo "Gebruiker is niet bewerkt!"; $this->autoRender = false; } } else { $this->request->data = $this->User->read(null, $id); } $groups = $this->User->Group->find('list'); $this->set(compact('groups')); $this->set('user', $this->User->read(null, $id)); } } /******* index.ctp ******/ <div class="span-12"> //here the foreach to get the list, not relevant //the link you see 'Bewerk' (dutch, edit in english) is made with $this->Js->link as you can see below <?php echo $this->Js->link('Bewerk', array('controller' => 'users', 'action' => 'edit', $user['User']['id']), array('update' => '#changedisplay')); ?> </div> <div id="changedisplay" class="span-11 prepend-1 last border-vertical"> //if you click on 'Bewerk' next to a user (see link above) the view file edit.ctp will load in here with the right user info </div> <?php echo $this->Js->writeBuffer(); ?> /****** edit.ctp ******/ //form code to update the user, also not relevant //below is the 'Opslaan' button (save in english) to save a user, this is a javascript link because we can display a flash message then but I took that out of the code because it is not relevant <?php echo $this->Js->submit('Opslaan', array('class' => 'button right', 'div' => false)); ?> <?php echo $this->Js->writeBuffer(); ?> ---------------------- So as you can see the edit.ctp file is rendered in the index.ctp using ajax and javascript. Nothing wrong here, everything is working fine. But we can't save one thing we have been struggling with. When you save a user the data in the database gets updated and you can immediately see that in the right side of the page (to edit a user - edit.ctp), but the left side of the page (the list of users - index.ctp) doesn't get updated. So if you change the name Femke van Gemert to Femke Gemert and save it, it gets updated on the right side, but on the left side in the list it still says Femke van Gemert. My question is: How can you refresh the list on the left side? the biggest problem is that if you do a refresh with command+R (on mac) then the list of users gets updated, but you lose the left side, because it isn't in the changedisplay div anymore. So I need a way to update the users list from the screen that I showed above, without doing a hard refresh (refreshing the whole page), just the users list. I hope you understand what I am trying to do and I really hop you can help me! -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
