Yii Framework Forum: yiinfinite-scroll - extension not working for me - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

yiinfinite-scroll - extension not working for me Not able to use ajaxlink in yiinfinite-scroll - extension Rate Topic: -----

#1 User is offline   alanselvam 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 02-May 11

Posted 31 July 2012 - 09:24 AM

Hi, i have used this extension and facing one issue. Here's my code

In protected/view folder, my index.php file

<div id="posts" class="span5">
<?php foreach($posts as $post): ?>
    <div class="post">
        <div class="row ">
        <?php
            $this->beginWidget('CMarkdown', array('purifyOutput'=>true));
            echo $post->content;
            $this->endWidget();
        ?>
    </div>
      <div class="row">
 
        <?php echo CHtml::link('<i class="icon-comment"></i> Comments ('.$post->commentCount.')',$post->url.'#comments'); ?> 
        <?php echo "id".$post->id;?>
 
       <?php echo CHtml::htmlButton('<i class="icon-cog icon-white"></i> Subscribe',
             array('data-loading-text'=>'Subscribed',
             'class'=>'btn btn-success',
             'ajax' => array(
                                    'type'=>'POST',
 
                                    'url'=>CController::createUrl('headlines/Create/id/'.$post->id),        
                                    'update'=>'#userIdAvailability', 
                                        'beforeSend' => 'function(){
                                            $("#userIdLoading").show();}',
                                    'complete' => 'function(){
                                            }'
                                            //$("#userIdLoading").hide();
                        ),
 
              'type'=>'button'));
 
              ?>
              <div id="userIdAvailability">
            <span style="" id="userIdLoading">Loading...</span></div>
         </div>
    </div>
 
<?php endforeach; ?>
</div>
<?php $this->widget('ext.yiinfinite-scroll.YiinfiniteScroller', array(
    'contentSelector' => '#posts',
    'itemSelector' => 'div.post',
    'loadingText' => 'Loading...',
    'donetext' => 'This is the end... my only friend, the end',
    'pages' => $pages,
)); ?>


My controller file postcontroller.php

public function actionIndex()
    {
 
        $model=new Post;
        if(isset($_POST['Post']))
        {
            $model->attributes=$_POST['Post'];
            if($model->save())
                $this->redirect(array('view','id'=>$model->id));
        }
 
        $criteria = new CDbCriteria;
            $total = Post::model()->count();
 
            $pages = new CPagination($total);
            $pages->pageSize = 5;
            $pages->applyLimit($criteria);
 
            $posts = Post::model()->findAll($criteria);
 
            if(isset($_GET['tag']))
            $criteria->addSearchCondition('tags',$_GET['tag']);
 
        $this->render('index', array(
                'posts' => $posts,
                'pages' => $pages,
                'model' => $model
            ));
    }


Noticed Issue:

In ajax button link click, i am not getting proper post id value, I put page size value as 5. Based on this, In every 5 post, I am getting ajax id value 1 to 5. If loader loading next set of 5 posts then it will reset those post id values. I mean, next 5 to 10 post also, i am getting post id values as 1 to 6.

Note:

I am trying to implement this extension with twitter bootstrap yii extension.

Please help me to resolve this issue
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users