Il 18/04/2012 13:01, Timo ha scritto:
Thanks a lot for your answer, it helped me a lot!

I see how elements can be used for what I am trying to do. I tried the simple example from the link you provided, so now I can populate multiple ares of one page with different views - that's great!

What I don't quite grasp is the usefulness of adding a helper as you mentioned in your last paragraph. So basically the helper would get all the data for my elements instead of me calling requestAction multiple times?

I was told that AJAX can be used to put content into element areas (via requestAction, too?), e.g. I have my slideout visible which shows a data entry, then, with my table still visible in the main content area, I choose edit on a different entry and instead of loading the page anew, the slideout element loads new content. How would one go about this task? A simple example would be enough to get me started, since I cannot find any useful ones, e.g. a button that triggers an element to be filled with a different view. I am aware of the .load function in JQuery ( http://api.jquery.com/load/ ), but that does not explain how to include such functionality in a CakePhp environment. Can I simply use something like 'controllername/add' as url parameter for load?
I use it in this way:
$("#someelement").load("/controller/action div.index");
loads html content of div.index in #someelement

You can handle it better with $.post / $.get handling the html response
$.get('controller/action', function(html){
  var myHtml = $(html);
  $("#something").replace( myHtml.find("#something").html() );
});

This works faster if you create an empty layout and print only the $content_for_layout, I use it with a custom extension eg. controlller/index.dhtml give me only the action response, without the whole layout code around.



As I see it, one issue remains despite the element solution (which might result from my limited Cake knowledge) -
...
Is there a way to put for example the rendered view of "View/Company/add.ctp" into an element?
...

I suggest you to look at the new -cool- templating system (from 2.1 I think)
http://book.cakephp.org/2.0/en/views.html

Luca

--
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

Reply via email to