Wednesday, April 18, 2012

Re: Some Issues: multiple views on one page and help with javascript

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?

As I see it, one issue remains despite the element solution (which might result from my limited Cake knowledge)  - concrete example: The application has tables for companies, users and posts, each table and corresponding controller has index / add / view(show the data) / edit views. Index is displayed in the main area, the other views are supposed to be displayed in the slideout. 
Would I not need many different element specifications depending 
a) on the chosen table
b) the chosen option (add / edit / etc) ?

Is there a way to put for example the rendered view of "View/Company/add.ctp" into an element? Because as far as I understand requestAction, I can only get the data provided by the controller (which makes sense due to the MVC pattern) and this data still has to be echoed and styled. And that is the problem since there is not a common style for add / edit / view (add and edit would have inputs for data values, view would use labels). My thought would be to put those options into one element and control which style is used by a parameter given to the element, I just want to know if that is viable or if there is another, better way to do this. 

I hope that was somewhat intelligible :)
Many thanks in advance for any helpful advice


Timo

--
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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: