Can anyone who help me to figure out the following questions?
A. Like the subject said. Normally when u loading a new page like index.php, all the elements or DIVs are loading simultaneously. How Can I make all the DIVs asynchronous or one by one?
B. How Can I reload or refresh a single DIV by clicking?
Thanks. I think it slove the question B. To click "todo" to load the "todo" tasks.
BUT, I think it is not my goal for A. How the Divs, for instance, three Divs, to load indivially? Like the www.netvibes.com. Each elements are loading according their speed or asynchronous.
Should I creat a new controller ,modify the controller or modify the .thtml files to do this ?
If you look back again at Graham Bird's 'tutorial', in the view you'll see an example of the $option['update'] option, I agree it's difficult know from the documentation that you are supposed to remove the $option and stick it in an array....
I think I should add a event-onload to the body tag, to do it when the page is loading and let the divs to load Asynchronous.
I chech the remoteFunction: Creates JavaScript function for remote AJAX call.
This function creates the javascript needed to make a remote call it is primarily used as a helper for linkToRemote.
I am not so clear about the defination. For remote AJAX call? I have an idea just add an onload event using Ajax.Updater in the body tag. Like u said it converts it to use the Ajax.Updater.
Is it the same function? Just another name in Cakephp rather than called Ajax.Updater in prototype?
Is the Right code for body Tag ? But I am not clear about what is the 'window' and 'load' . Is the part of onload event or what ? I can't find any refrence.
> But I am not clear about what is the 'window' and 'load'.
The Window object is the highest level js object which corresponds to the web browser window. The 'load' is the argument that you are passing into the 'event' function, corresponding to the type of event you are attaching to. If you want an onclick event, you pass in 'click', for onblur->'blur' etc. The function prepends it with 'on' depending on the type of browser that you have.
> Is the part of onload event or what ? I can't find any refrence.
Hmm. If you want to do it this way (there are a few ways to do this) then the body tag could just stay like this:
<body>
In your <head> (maybe) you should have a script tag or a call to a .js with the following:
<script type="text/javascript">
// attach the event to the body tag and attach the doAjaxCall() to the event $javascript->event('window','load', 'doAjaxCall()', false);
function doAjaxCall () { $ajax->remoteFunction(array("url"=>"/posts/load/","update"=>"posts_view","t ype"=>"asynchronous"));
}
</script>
I haven't tested this, so you'll probably need to play with it to get it to work. Hope this helps...
I put the code below between head. It works! For the function doAjaxCall( ), I really don't know where should I put. So, I just combine the two parts together. Now, I know the logic to do it.