Quantcast

Ajax pagination returns the whole page instead of the requested div

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Ajax pagination returns the whole page instead of the requested div

JonStark
Hello everyone.

I'm trying to do a Twitter style auto- load more when scrolling :

                         <?php if (!$isAjax):?>
  <div id="postList">
  <?php endif;?>
   
  <?php echo $this->element('posts'); ?></div>
   
  <?php if (!$isAjax):?>
  </div>
  <?php endif;?>
   
  <?php if (!$isAjax):?>
  <?php
  echo $this->Html->script('jquery', false);
  $maxPage = $this->Paginator->counter('%pages%');
  ?>
  <script type="text/javascript">
  var lastX = 0;
  var currentX = 0;
  var page = 1;
  $(window).scroll(function () {
  if (page < <?php echo $maxPage;?>) {
  currentX = $(window).scrollTop();
  if (currentX - lastX > 300 * page) {
  lastX = currentX;
  page++;
  $.get('posts/page:' + page, function(data) {
  $('#postList').append(data);
  });
  }
  }
  });
  </script>
  <?php endif;?>
   
  <?php echo $this->Js->writeBuffer(); ?>
This should updates only the div "postList" but it returns the whole page in the view. In my controller, I have public $components = array('RequestHandler'); activated, and $this->set('isAjax', $this->RequestHandler->isAjax()); in my function. What am I doing wrong ? Thanks a lot !

--
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
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Ajax pagination returns the whole page instead of the requested div

Tilen Majerle
just use $this->request->is('ajax')

you don't need to include RequestHandler component.
OFC, you have to be on 2.x cake that will work this :)

<?php echo $this->element('posts'); ?></div>

why si "</div>" there ?

--
Lep pozdrav, Tilen Majerle



2012/7/1 JonStark <[hidden email]>
Hello everyone.

I'm trying to do a Twitter style auto- load more when scrolling :

                         <?php if (!$isAjax):?>
  <div id="postList">
  <?php endif;?>
   
  <?php echo $this->element('posts'); ?></div>
   
  <?php if (!$isAjax):?>
  </div>
  <?php endif;?>
   
  <?php if (!$isAjax):?>
  <?php
  echo $this->Html->script('jquery', false);
  $maxPage = $this->Paginator->counter('%pages%');
  ?>
  <script type="text/javascript">
  var lastX = 0;
  var currentX = 0;
  var page = 1;
  $(window).scroll(function () {
  if (page < <?php echo $maxPage;?>) {
  currentX = $(window).scrollTop();
  if (currentX - lastX > 300 * page) {
  lastX = currentX;
  page++;
  $.get('posts/page:' + page, function(data) {
  $('#postList').append(data);
  });
  }
  }
  });
  </script>
  <?php endif;?>
   
  <?php echo $this->Js->writeBuffer(); ?>
This should updates only the div "postList" but it returns the whole page in the view. In my controller, I have public $components = array('RequestHandler'); activated, and $this->set('isAjax', $this->RequestHandler->isAjax()); in my function. What am I doing wrong ? Thanks a lot !

--
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
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php

--
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
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Ajax pagination returns the whole page instead of the requested div

JonStark
Thanks for the head up !

But still, doesn't solve my problem :(

Whenever I try to paginate a update just a given div, I get the full layout in response....

Le dimanche 1 juillet 2012 20:18:10 UTC+2, MaJerle.Eu a écrit :
just use $this->request->is('ajax')

you don't need to include RequestHandler component.
OFC, you have to be on 2.x cake that will work this :)

<?php echo $this->element('posts'); ?></div>

why si "</div>" there ?

--
Lep pozdrav, Tilen Majerle



2012/7/1 JonStark
Hello everyone.

I'm trying to do a Twitter style auto- load more when scrolling :

                         <?php if (!$isAjax):?>
  <div id="postList">
  <?php endif;?>
   
  <?php echo $this->element('posts'); ?></div>
   
  <?php if (!$isAjax):?>
  </div>
  <?php endif;?>
   
  <?php if (!$isAjax):?>
  <?php
  echo $this->Html->script('jquery', false);
  $maxPage = $this->Paginator->counter('%pages%');
  ?>
  <script type="text/javascript">
  var lastX = 0;
  var currentX = 0;
  var page = 1;
  $(window).scroll(function () {
  if (page < <?php echo $maxPage;?>) {
  currentX = $(window).scrollTop();
  if (currentX - lastX > 300 * page) {
  lastX = currentX;
  page++;
  $.get('posts/page:' + page, function(data) {
  $('#postList').append(data);
  });
  }
  }
  });
  </script>
  <?php endif;?>
   
  <?php echo $this->Js->writeBuffer(); ?>
This should updates only the div "postList" but it returns the whole page in the view. In my controller, I have public $components = array('RequestHandler'); activated, and $this->set('isAjax', $this->RequestHandler->isAjax()); in my function. What am I doing wrong ? Thanks a lot !

--
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
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php

--
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
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Ajax pagination returns the whole page instead of the requested div

lowpass
I can't speak to the example code you provided as I don't use Cake's
JSHelper for AJAX.

Does the full layout include the data you wanted? Or does it just have
what you'd see when first arriving at the page? Does your controller
action have a redirect? Does the returned HTML include an error or
notice of any kind?

On Sun, Jul 1, 2012 at 2:27 PM, JonStark <[hidden email]> wrote:

> Thanks for the head up !
>
> But still, doesn't solve my problem :(
>
> Whenever I try to paginate a update just a given div, I get the full layout
> in response....
>
> Le dimanche 1 juillet 2012 20:18:10 UTC+2, MaJerle.Eu a écrit :
>>
>> just use $this->request->is('ajax')
>>
>> you don't need to include RequestHandler component.
>> OFC, you have to be on 2.x cake that will work this :)
>>
>> <?php echo $this->element('posts'); ?></div>
>>
>> why si "</div>" there ?
>>
>> --
>> Lep pozdrav, Tilen Majerle
>> http://majerle.eu
>>
>>
>>
>> 2012/7/1 JonStark
>>>
>>> Hello everyone.
>>>
>>> I'm trying to do a Twitter style auto- load more when scrolling :
>>>
>>>>                          <?php if (!$isAjax):?>
>>>>
>>>>   <div id="postList">
>>>>   <?php endif;?>
>>>>
>>>>   <?php echo $this->element('posts'); ?></div>
>>>>
>>>>   <?php if (!$isAjax):?>
>>>>   </div>
>>>>   <?php endif;?>
>>>>
>>>>   <?php if (!$isAjax):?>
>>>>   <?php
>>>>   echo $this->Html->script('jquery', false);
>>>>   $maxPage = $this->Paginator->counter('%pages%');
>>>>   ?>
>>>>   <script type="text/javascript">
>>>>   var lastX = 0;
>>>>   var currentX = 0;
>>>>   var page = 1;
>>>>   $(window).scroll(function () {
>>>>   if (page < <?php echo $maxPage;?>) {
>>>>   currentX = $(window).scrollTop();
>>>>   if (currentX - lastX > 300 * page) {
>>>>   lastX = currentX;
>>>>   page++;
>>>>   $.get('posts/page:' + page, function(data) {
>>>>   $('#postList').append(data);
>>>>   });
>>>>   }
>>>>   }
>>>>   });
>>>>   </script>
>>>>   <?php endif;?>
>>>>
>>>>   <?php echo $this->Js->writeBuffer(); ?>
>>>
>>> This should updates only the div "postList" but it returns the whole page
>>> in the view. In my controller, I have public $components =
>>> array('RequestHandler'); activated, and $this->set('isAjax',
>>> $this->RequestHandler->isAjax()); in my function. What am I doing wrong ?
>>> Thanks a lot !
>>>
>>> --
>>> 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
>>> [hidden email] For more options, visit this group
>>> at http://groups.google.com/group/cake-php
>>
>>
> --
> 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
> [hidden email] For more options, visit this group at
> http://groups.google.com/group/cake-php

--
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
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Ajax pagination returns the whole page instead of the requested div

darkangel-2
In reply to this post by JonStark
Did you fix it? I'm facing the same issue :S

On Sunday, July 1, 2012 12:27:27 PM UTC-6, JonStark wrote:
Thanks for the head up !

But still, doesn't solve my problem :(

Whenever I try to paginate a update just a given div, I get the full layout in response....

Le dimanche 1 juillet 2012 20:18:10 UTC+2, MaJerle.Eu a écrit :
just use $this->request->is('ajax')

you don't need to include RequestHandler component.
OFC, you have to be on 2.x cake that will work this :)

<?php echo $this->element('posts'); ?></div>

why si "</div>" there ?

--
Lep pozdrav, Tilen Majerle



2012/7/1 JonStark
Hello everyone.

I'm trying to do a Twitter style auto- load more when scrolling :

                         <?php if (!$isAjax):?>
  <div id="postList">
  <?php endif;?>
   
  <?php echo $this->element('posts'); ?></div>
   
  <?php if (!$isAjax):?>
  </div>
  <?php endif;?>
   
  <?php if (!$isAjax):?>
  <?php
  echo $this->Html->script('jquery', false);
  $maxPage = $this->Paginator->counter('%pages%');
  ?>
  <script type="text/javascript">
  var lastX = 0;
  var currentX = 0;
  var page = 1;
  $(window).scroll(function () {
  if (page < <?php echo $maxPage;?>) {
  currentX = $(window).scrollTop();
  if (currentX - lastX > 300 * page) {
  lastX = currentX;
  page++;
  $.get('posts/page:' + page, function(data) {
  $('#postList').append(data);
  });
  }
  }
  });
  </script>
  <?php endif;?>
   
  <?php echo $this->Js->writeBuffer(); ?>
This should updates only the div "postList" but it returns the whole page in the view. In my controller, I have public $components = array('RequestHandler'); activated, and $this->set('isAjax', $this->RequestHandler->isAjax()); in my function. What am I doing wrong ? Thanks a lot !

--
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
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="BNs4_gbEXYgJ">cake-php+u...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Ajax pagination returns the whole page instead of the requested div

Miqdad Ali
Try this one..

Add this code starting..

<?php
     if ($isAjax):
          $this->layout = '';
     endif;
?>

-
Miqdad Ali K
+919995258790
http://www.miqdadalik.com




On Fri, Aug 31, 2012 at 4:29 AM, darkangel <[hidden email]> wrote:
Did you fix it? I'm facing the same issue :S


On Sunday, July 1, 2012 12:27:27 PM UTC-6, JonStark wrote:
Thanks for the head up !

But still, doesn't solve my problem :(

Whenever I try to paginate a update just a given div, I get the full layout in response....

Le dimanche 1 juillet 2012 20:18:10 UTC+2, MaJerle.Eu a écrit :
just use $this->request->is('ajax')

you don't need to include RequestHandler component.
OFC, you have to be on 2.x cake that will work this :)

<?php echo $this->element('posts'); ?></div>

why si "</div>" there ?

--
Lep pozdrav, Tilen Majerle



2012/7/1 JonStark
Hello everyone.

I'm trying to do a Twitter style auto- load more when scrolling :

                         <?php if (!$isAjax):?>
  <div id="postList">
  <?php endif;?>
   
  <?php echo $this->element('posts'); ?></div>
   
  <?php if (!$isAjax):?>
  </div>
  <?php endif;?>
   
  <?php if (!$isAjax):?>
  <?php
  echo $this->Html->script('jquery', false);
  $maxPage = $this->Paginator->counter('%pages%');
  ?>
  <script type="text/javascript">
  var lastX = 0;
  var currentX = 0;
  var page = 1;
  $(window).scroll(function () {
  if (page < <?php echo $maxPage;?>) {
  currentX = $(window).scrollTop();
  if (currentX - lastX > 300 * page) {
  lastX = currentX;
  page++;
  $.get('posts/page:' + page, function(data) {
  $('#postList').append(data);
  });
  }
  }
  });
  </script>
  <?php endif;?>
   
  <?php echo $this->Js->writeBuffer(); ?>
This should updates only the div "postList" but it returns the whole page in the view. In my controller, I have public $components = array('RequestHandler'); activated, and $this->set('isAjax', $this->RequestHandler->isAjax()); in my function. What am I doing wrong ? Thanks a lot !

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

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 

--
Like Us on FacekBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Loading...