Discussion:
jQuery & ajax pagination in 1.3
Scronkey
2009-12-12 00:51:48 UTC
Permalink
Using Mark Story's guide for mootools, pagination and the new JS
helper (http://mark-story.com/posts/view/creating-simple-ajax-
pagination-with-cakephp-1-3-and-mootools) I have managed to get
pagination somewhat working using jQuery.

I say somewhat because only every second request uses ajax (clicking
sort or the pagination links). Every alternate request results in a
full request. This is confirmed through Firebug however it's quite
clear as the whole page refreshes.

When I place alerts in the before and success handlers (in the
$paginator->options array) they only fire after the full refresh,
which seems odd.

Has anyone seen this before or have any ideas on how I might diagnose
this further?

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php-/***@public.gmane.org
To unsubscribe from this group, send email to
cake-php+unsubscribe-/***@public.gmane.org For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Scronkey
2009-12-14 08:44:50 UTC
Permalink
I believe I know what's going on now but I'm not sure how to fix it.

On the first (successful) ajax call the next set of content is loaded,
including the paginator links, however the paginator links are not
successfully bound to a jQuery ajax call, therefore the next click
results in a normal page request which then results in correctly bound
events.

Marks post mentions the use of 'evalScripts' => true to chain the ajax
requests however this seems to have no effect with jQuery (his example
uses MooTools).

Is there a way I can ensure the events are rebound using jsHelper with
jQuery after the ajax call?

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php-/***@public.gmane.org
To unsubscribe from this group, send email to
cake-php+unsubscribe-/***@public.gmane.org For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Joe Theory
2009-12-15 19:21:21 UTC
Permalink
I am having the same problem and can confirm that it happens
specifically when using JQuery. Using the Js Helper with Mootools
works just fine.
Post by Scronkey
I believe I know what's going on now but I'm not sure how to fix it.
On the first (successful) ajax call the next set of content is loaded,
including the paginator links, however the paginator links are not
successfully bound to a jQuery ajax call, therefore the next click
results in a normal page request which then results in correctly bound
events.
Marks post mentions the use of 'evalScripts' => true to chain the ajax
requests however this seems to have no effect with jQuery (his example
uses MooTools).
Is there a way I can ensure the events are rebound using jsHelper with
jQuery after the ajax call?
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php-/***@public.gmane.org
To unsubscribe from this group, send email to
cake-php+unsubscribe-/***@public.gmane.org For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Dave
2009-12-16 10:27:48 UTC
Permalink
I have run into issues like this as well. For some reason sometimes when
content is pulled in via ajax I need to call $js->writeBuffer; at the bottom
of the view in the action which is called to get all of the javascript to
echo properly.

It kind of makes sense, if you have $js->writeBuffer at the bottom of your
layout, and your layout isn't refreshed, then you won't get the javascript
from the new view

I am not sure if this is how it is supposed to work, but that's just what
i've noticed
Post by Joe Theory
I am having the same problem and can confirm that it happens
specifically when using JQuery. Using the Js Helper with Mootools
works just fine.
Post by Scronkey
I believe I know what's going on now but I'm not sure how to fix it.
On the first (successful) ajax call the next set of content is loaded,
including the paginator links, however the paginator links are not
successfully bound to a jQuery ajax call, therefore the next click
results in a normal page request which then results in correctly bound
events.
Marks post mentions the use of 'evalScripts' => true to chain the ajax
requests however this seems to have no effect with jQuery (his example
uses MooTools).
Is there a way I can ensure the events are rebound using jsHelper with
jQuery after the ajax call?
Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group, send email to
http://groups.google.com/group/cake-php?hl=en
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php-/***@public.gmane.org
To unsubscribe from this group, send email to
cake-php+unsubscribe-/***@public.gmane.org For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
mark_story
2009-12-16 20:39:10 UTC
Permalink
Yeah you need the writeBuffer() at the bottom of the view, or in your
ajax layout. Otherwise the event scripts don't get sent along. I'll
have to look into the jquery issue, I thought jquery did global eval()
on all the script blocks in an html response, but seems I might have
been wrong.

-Mark
I have run into issues like this as well.  For some reason sometimes when
content is pulled in via ajax I need to call $js->writeBuffer; at the bottom
of the view in the action which is called to get all of the javascript to
echo properly.
It kind of makes sense, if you have $js->writeBuffer at the bottom of your
layout, and your layout isn't refreshed, then you won't get the javascript
from the new view
I am not sure if this is how it is supposed to work, but that's just what
i've noticed
Post by Joe Theory
I am having the same problem and can confirm that it happens
specifically when using JQuery.   Using the Js Helper with Mootools
works just fine.
Post by Scronkey
I believe I know what's going on now but I'm not sure how to fix it.
On the first (successful) ajax call the next set of content is loaded,
including the paginator links, however the paginator links are not
successfully bound to a jQuery ajax call, therefore the next click
results in a normal page request which then results in correctly bound
events.
Marks post mentions the use of 'evalScripts' => true to chain the ajax
requests however this seems to have no effect with jQuery (his example
uses MooTools).
Is there a way I can ensure the events are rebound using jsHelper with
jQuery after the ajax call?
Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group, send email to
http://groups.google.com/group/cake-php?hl=en
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php-/***@public.gmane.org
To unsubscribe from this group, send email to
cake-php+unsubscribe-/***@public.gmane.org For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Joe Theory
2009-12-17 20:42:03 UTC
Permalink
Jquery is the only engine that seems to have issues Mark. Thanks for
this Js helper by the way. So nice on so many levels.
Post by mark_story
Yeah you need the writeBuffer() at the bottom of the view, or in your
ajax layout. Otherwise the event scripts don't get sent along.  I'll
have to look into the jquery issue, I thought jquery did global eval()
on all the script blocks in an html response, but seems I might have
been wrong.
-Mark
I have run into issues like this as well.  For some reason sometimes when
content is pulled in via ajax I need to call $js->writeBuffer; at the bottom
of the view in the action which is called to get all of the javascript to
echo properly.
It kind of makes sense, if you have $js->writeBuffer at the bottom of your
layout, and your layout isn't refreshed, then you won't get the javascript
from the new view
I am not sure if this is how it is supposed to work, but that's just what
i've noticed
Post by Joe Theory
I am having the same problem and can confirm that it happens
specifically when using JQuery.   Using the Js Helper with Mootools
works just fine.
Post by Scronkey
I believe I know what's going on now but I'm not sure how to fix it.
On the first (successful) ajax call the next set of content is loaded,
including the paginator links, however the paginator links are not
successfully bound to a jQuery ajax call, therefore the next click
results in a normal page request which then results in correctly bound
events.
Marks post mentions the use of 'evalScripts' => true to chain the ajax
requests however this seems to have no effect with jQuery (his example
uses MooTools).
Is there a way I can ensure the events are rebound using jsHelper with
jQuery after the ajax call?
Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others
with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group, send email to
http://groups.google.com/group/cake-php?hl=en
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php-/***@public.gmane.org
To unsubscribe from this group, send email to
cake-php+unsubscribe-/***@public.gmane.org For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Continue reading on narkive:
Loading...