Re: How To Load Divs Asynchronous For Index.php?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: How To Load Divs Asynchronous For Index.php?

Eric-131

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 ?


Ismael S. Kafeltz wrote:
> Take a look in this source code, it is easy to understand:
>
> http://www.grahambird.co.uk/cake/tutorials/ajax.php


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: How To Load Divs Asynchronous For Index.php?

cadraig

If I understand your problem correctly you may just want to make each
div synchronous.

$options ['type']         // Either 'asynchronous' (default), or
'synchronous'.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: How To Load Divs Asynchronous For Index.php?

Eric-131

I am not so clear. The div synchronous means each div are loading at
the same time. Is it correct?

BUT for the example website www.netvibes.com, is it the each div are
loading asynchronous or indivually?

AND also, if I want to load the index page to load like
www.netvibes.com, Where can I write the code like u $options['type'].

Thanks. I am a rookie.


Tim wrote:
> If I understand your problem correctly you may just want to make each
> div synchronous.
>
> $options ['type']         // Either 'asynchronous' (default), or
> 'synchronous'.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: How To Load Divs Asynchronous For Index.php?

Eric-131
In reply to this post by cadraig

For the Question B.
I check the script.aculo.us Wiki and got one solution.
use Ajax.Updater for onclick

The code below:
onclick="new
Ajax.Updater('posts_view','/posts/refresh',{asynchronous:true,evalScritps:true});return
false"

Is it the right way to do this even it works?

Thanks.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: How To Load Divs Asynchronous For Index.php?

cadraig

Hi Eric,
I think you might be getting your synchronous and asynchronous in a
muddle.

Synchronous -> browser stops working and waits for reply from a single
request
Asynchronous -> browser makes multiple requests at the same time...!

See:  http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request

Most people seem to think that synchronous requests are a bad idea
e.g. http://ajaxblog.com/archives/2005/05/25/synchronous-requests-bad
https://blueprints.dev.java.net/ajax-faq.html#synchronous

On Oct 30, 12:56 pm, "Eric" <[hidden email]> wrote:

> For the Question B.
> I check the script.aculo.us Wiki and got one solution.
> use Ajax.Updater for onclick
>
> The code below:
> onclick="new
> Ajax.Updater('posts_view','/posts/refresh',{asynchronous:true,evalScritps:true});return
> false"
>
> Is it the right way to do this even it works?
>
> Thanks.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: How To Load Divs Asynchronous For Index.php?

cadraig

Hi Eric

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

        print $ajax->link('Delete', 'delete/' . $item['id'],
array('update'=>'tasks_done'));

If you want to do it on load of the page you'll probably need an onload
event attached to the body tag.

This should call a function which (if you want to have it cakeified)
should maybe have one blocks of code for each div you want to update:

                        echo $ajax->remoteFunction(
                        array("url"=>"/controller/action/",
                                  "update"=>"divToUpdate",
                                  "type"=>"asynchronous"
                                  )
                        );

View the source after its run and you'll see it converts it to use the
prototype.js object Ajax.Updater

If you change the type to synchronous, each div should load one after
the other, rather than all at once.
Hope this helps

Tim


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: How To Load Divs Asynchronous For Index.php?

Eric-131
In reply to this post by cadraig

Thanks.

I am getting clear about 'S 'and 'A'.

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?

Thanks.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: How To Load Divs Asynchronous For Index.php?

Eric-131
In reply to this post by cadraig

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.

<body onload="<?=$ajax->javascript->event('window','load',
$ajax->remoteFunction(
            array("url"=>"/posts/load/",
                                  "update"=>"posts_view",
                                  "type"=>"asynchronous"
                    )

                      ) ); ">


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: How To Load Divs Asynchronous For Index.php?

cadraig

Hi Zou,

>  Is the Right code for body Tag ?

No, I don't think this will work as it stands.

>  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","type"=>"asynchronous"));
}

</script>

I haven't tested this, so you'll probably need to play with it to get
it to work.
Hope this helps...

Cheers


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: How To Load Divs Asynchronous For Index.php?

Eric-131

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.

Thanks.Tim
Have a good Day!!


<head>
<?php print
$javascript->event('window','load',$ajax->remoteFunction(array("url"=>"/posts/index/","update"=>"posts_view","type"=>"asynchronous")),false)?>
</head>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---