> well, back on topic, hydra12, can you give me some examples on how you set
> up your pages as far as the ajax page, did you create a view for each one of
> your functions. I think that is what is giving me a hard time to grasp.
I did create a view for each function. In fact, right now I'm using
the default views that bake.php created for me. I have a users table
that I can use for this example. Bake created index, add, edit,
delete, and view for me. I created another function, userList.
Userlist has a view with 2 divs: menu and info. When you browse to
userList (mine is apps.localhost/ekklesia/users/userlist), it lists the
users in the left-hand column(menu). When you click on a name, it
loads the users function view (created by bake) into info. Here's how
I did it:
//view function created by bake.php
function view($id = null) {
$this->User->recursive = 2;
$this->layout = 'Ajax'; //added by me so that the default layout
doesn't get loaded into my userInfo column
if(!$id) {
$this->Session->setFlash('Invalid id for User.');
$this->redirect('/users/index');
}
$this->set('user', $this->User->read(null, $id));
}
//userList function
function userList()
{
$this->User->recursive = 0;
$this->set('users', $this->User->findAll());
}
//user_list.ctp(or .thtml if you are using cake1.1)
<table style="width: 100%; border: 1px solid black; background-color:
white;">
<tr>
<td id="menuContainer" style="width: 20%; ">
<div id="menu" style="text-align: left;">
<ul>
<?php foreach ($users as $user): ?>
<li><?php echo
$html->link($user['User']['name'],'view/'.$user['User']['id']); ?></li>
<?php endforeach; ?>
</ul>
</div>
</td>
<td id="infoContainer" style="width: 80%;">
<div id="info" style="text-align: left;">
</div>
</td>
</tr>
</table>
//add this to default.ctp layout
<?php echo $javascript->link('jquery'); ?>
<?php echo $javascript->link('ekklesia'); ?>
//ekklesia.js goes in webroot/js along with jquery.js
$(document).ready(function() {
$("#menu > ul > li > a").click(function() {
$("div#info").load(this.href);
return false;
});
});
Here's what happens: when you go to users/userList, it loads the
default layout and the user_list.ctp view. When the document is ready,
jquery captures all of my userName links because they are in #menu in a
ul > li and they are <a> links. When jquery detects a click on one of
these links, it loads the page the link goes to into a div with the id
'info'. Return false tells the browser not to follow the link.
I hope that helps.
hydra12
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---