What you need to do is write an index action for your users_controller
like you would if you were NOT using ajax or reusing that action at
all.
Once you have that done, modify that function to check isset( $this-
>params['requested'] ) to see if the view action if being called via
the requestAction function.

***

function index( )
    $users = $this->User->findAll( );
    if( isset( $this->params['requested'] ) ){
        return $users;
    }
    $this->set( 'users', $users );
}

Then you create an element - users_list.ctp

if( !isset( $_data ) ) {
   $_data = $this->requestAction( array( 'controller' => 'users',
'action' => 'index' ) );
}
<table>
foreach( $_data as $row _) {
    <tr><td>echo use data</td></tr>
}
</table>

You can then use the element in your users_controller index view file.
$this->renderElement( 'users_list', array( '_data' => $users );

For a good write up check out the bakery articles..
http://bakery.cakephp.org/articles/view/creating-reusable-elements-with-requestaction
http://bakery.cakephp.org/articles/view/cache-elements-individually-for-each-user
http://bakery.cakephp.org/articles/view/optimizing-your-cakephp-elements-and-views-with-caching

This will show you how to create these reusable elements as well as
how to cache them based on the freshness of the model data, timestamps
and on a per user / instance basis

Enjoy.


and in other view without the $users data $this-
>renderElement( 'users_list' );
On Aug 16, 2:42 pm, "Christophe C." <[EMAIL PROTECTED]> wrote:
> up :(
> Any suggestions ?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to