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