Pagination is not working

Regards,

On index.php




<?php $this->widget('zii.widgets.jui.CJuiTabs', array(

  'tabs'=>array(

    'Residential'=>array(

      'ajax'=>CController::createUrl('property/_residential'),

      'id'=>'Residential'

     ),

  ),

  'options'=>array(

    'idPrefix'=>'ui-tabs-propertySearch',

  ),

  'id'=>'searchBox',

); ?>

<div id='#ajaxUpdate'></div>



_residential is a view having CHtml form. It has ajaxSubmitButton which updates div #ajaxUpdate on index.php

After showing results in CListView, it shows pages. Now on clicking on any of the page buttons, #ajaxUpdate is going blank. Does anyone have any idea about it?

How to debug this kind of problems… Please help.

Edit: @abajja : Thanks for notifying. I have changed the code. to CController::createUrl

This line has a syntax error ::->.


'ajax'=>CController::->createUrl('property/_residential'),

Bump

I am working on a live project using Yii! Please help…

Is it related to jquery .live() functionality which is absent with Yii CJuiTabs or CHtml ajaxSubmitButton ?

What will make disappear #ajaxUpdate div content without js errors and still firebug showing correct contents have been loaded using ajax!

Is trunk stable enough to be used in live project?

Yes, if you do not plan on using jquery UI in zii right away.

Thanks for reply!

I wanted to use zii… but it is very difficult to use. I finally figured out how to use CJuiTabs with contents loaded statically! Cause, making ajax’ request for each tab was slow for me. so I called renderPartial for all 3 views sending models to each n getting a content instead of direct echo (3rd option in renderPartial).

then sending all these 3 contents on one render() method where i can use…


<?php 'content'=>$tab1Content; ?>

Now I have one more problem.

Situation is like following.

3 tabs. I have forms in each. clicking on a button in tab1, i update a div outside tabs which is #ajaxUpdate.

this div have a button on which I want to open a jquery-ui dialog. How to use CJuiDialog to achieve this?

Please any example? or hint?

Also, there is very big concern…[b]

I have CListView inside that div, loaded dinamically after clicking on tab form. so when pages are loaded, on clicking _page/2(page navigation) it sends the number of requests equals to the number of times i have clicked the button in tab form. [/b]

Which means , as I keep on searching, without page refresh, site may become slow on clicking on page navigation.!!!

What is the wrong I have done? Please help…

Some (laboratory) code to work with tabs. Please note that I use the jquery.tools.min.js library.

controllers/InfoController.php





public function actionRohit() {

        $this->render('rohit');

    }


    public function action_residential() {

//your search for data e.g

//      $data = $info->findAllBySql($sql);

        $this->layout = 'r-3';

        $this->render('test', array('data'=>$data,'pages'=>$pages));

    }



views/rohit.php




<div class="ui-tabs ui-widget ui-widget-content ui-corner-all">

<ul class="css-tabs ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">


    <li class="ui-state-default ui-corner-top"><a href="<?php echo $this->createUrl('info/_residential');?>">Administració</a></li>


</ul>


<!-- tab "panes" -->

<div class="css-panes ui-tabs-panel ui-widget-content ui-corner-bottom">

    <div class="pane"></div>

</div>

</div>


<?php


Yii::app()->clientScript->registerScript('test_tabs_id',

	'$("ul.css-tabs").tabs("div.css-panes > div.pane", {effect : "ajax",

            onClick: function(){

                                $(".pane a").live("click", function() {

                                    $(".pane").load(this.href);

                                    return false;

                                });

                           }

            });',

        CClientScript::POS_READY);

// for presentation

Yii::app()->clientScript->registerCssFile('/path_to/css/smoothness/jquery-ui.css');

// you must download this library from http://flowplayer.org/tools/download.html

Yii::app()->clientScript->registerScriptFile('/path_to/js/jquery.tools.min.js');


?>



views/test.php




<table>

<?php foreach($data as $row): ?>

    <tr>

        <td><?php echo '<td>'.$row['name']?></td>

        <td><?php //print the list;?></td>

    </tr>

<?php endforeach; ?>

</table>

<?php $this->widget('CLinkPager',array('pages'=>$pages)); ?>




views/layout/r-3.php




<?php

echo $content;

?>




A lot of the Zii libraries uses ajax which I find to be very annoying. Havn’t talked with the other devs about this yet… but I see no point in making pagination use ajax, or tabs for that matter. And it’s not super easy to fall back to non-ajax either… You do in fact have to deal with live() jquery methods, or rebind the events if you want to use js within an ajax return

If you don’t want gridview/listview to use ajax pagination/sorting, simply configure its ajaxUpdate=false.

I see. But all the js scripts are registered whether you use ajax or not, including jquery, which I do not think is clean.

Personally I would be happier if we had CAjaxListView which extended CListView. Again I don’t think ajax helps anything in this case

Personally I liked the way pagination works… but I found that, while u send request for pagination, it again gets whole bunch of text like menu bar items, footer etc. If we are using pagination we should only get the data and jquery loaded on client side should do the work of fixing the values inside the box. Or may be some json response for these kind of things will be neat and light on bandwidth.

@jonah I think , not all js files like jquery or jquery-ui are registered by default. It depends on which components you are using and what is its dependency…

@abajja Thanks for the example :) It will surely help.

Please have a look at http://hubsonline.byethost3.com/

the search functionality. You will get the idea, what is happening. On click of send inquiry button, dialog opens up. Now on next search, it will not work as there are two divs added internally with same contents!

Also, when you search multiple times say 3 times, and then click on page navigation it sends 3 times request! The way I have put my code along with different views, causing this problems! But I don’t know how to solve it!

@rohit: You actually only need to send back the grid view result in ajax response. The code generated by crud tool is for simplicity, which saves you from writing a separate view file. There’s also a bug in 1.1.0 regarding the number of ajax requests, which has been fixed in svn already.

Thanks Qiang…

But I tried svn for my code, and still it sends multiple requests.

What might have gone wrong?

Is it because i create CListView dynamically using ajax every time I search?

Similar problem is there with dialog. It is adding div multiple times at the of body tag outside #page.

I don’t know how to stop that!

If I use CJuiDialog widget on same page with CListView it works, but on next search, it adds duplicate div at the end of <body> tag. So, stops working.

If I use widget on upper level at index page only, instead of _ajaxSearchResults page, it says, ("#inquiryForm").dialog dialog is not a function! What could be the reason?