Hi Gremlin,

What you said is all correct, etc, however there is still the issue of
creating a view and element for every ajax method, which is kinda what
Christophe was getting at by wanting to call $this->renderElement()
from the controller.

This is also something that kinda annoyed me, however you could solve
this problem by adding a clever beforeFilter method to your
controller, which would set the view to an "element view", and set
layout to ajax, etc, automatically taking the action name and passing
it to the view which would load an element by that name.

Something to think about - I might try this in the future.

Adam


On Aug 18, 6:48 am, gremlin <[EMAIL PROTECTED]> wrote:
> Somehow lost some of the post.
>
> Also in views that dont have a $users variable set you can use the
> element $this->renderElement( 'users_list' );
> Using ajax to return html snippets would work as well. - jquery style
> - $( '#element' ).load( Url/users/index ); would load the cached
> element into the #element.
>
> Remember you need to play with the RequestHandler component and either
> extension parsing or request handling code to serve the ajax view in a
> blank layout.
>
> Again have fun with this stuff. Let us know what you come up with.
>
> On Aug 17, 1:41 pm, gremlin <[EMAIL PROTECTED]> wrote:
>
> > 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-wi......
>
> > 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 cake-php@googlegroups.com
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