Yii Framework Forum: Pagination is not working - Yii Framework Forum

Jump to content

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

Pagination is not working CJuiTabs Ajax Rate Topic: -----

#1 User is offline   rohit 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 71
  • Joined: 08-July 09
  • Location:India

Posted 27 February 2010 - 03:34 AM

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 post has been edited by rohit: 27 February 2010 - 01:13 PM

0

#2 User is offline   abajja 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 108
  • Joined: 05-March 09
  • Location:Barcelona, Spain

Posted 27 February 2010 - 05:58 AM

This line has a syntax error ::->.
'ajax'=>CController::->createUrl('property/_residential'),

1

#3 User is offline   rohit 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 71
  • Joined: 08-July 09
  • Location:India

Posted 01 March 2010 - 06:54 AM

*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!
0

#4 User is offline   rohit 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 71
  • Joined: 08-July 09
  • Location:India

Posted 02 March 2010 - 01:58 AM

Is trunk stable enough to be used in live project?
0

#5 User is offline   jayrulez 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 348
  • Joined: 29-July 09

Posted 02 March 2010 - 06:42 AM

View Postrohit, on 02 March 2010 - 01:58 AM, said:

Is trunk stable enough to be used in live project?


Yes, if you do not plan on using jquery UI in zii right away.
php:
foreach(array('cat', 'dog', 'cow') as $animal) echo $animal."\n";

python:
[(animal, print(animal)) for animal in ['cat', 'dog', 'cow']]

ruby:
['cat', 'dog', 'cow'].each {|animal| puts animal}


You say Tomato, I say Tomato.
0

#6 User is offline   rohit 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 71
  • Joined: 08-July 09
  • Location:India

Posted 02 March 2010 - 07:45 AM

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...
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.


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..
0

#7 User is offline   abajja 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 108
  • Joined: 05-March 09
  • Location:Barcelona, Spain

Posted 02 March 2010 - 03:18 PM

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;
?>


0

#8 User is offline   jonah 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 733
  • Joined: 27-November 08
  • Location:California (US)

Posted 02 March 2010 - 06:55 PM

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
http://php-thoughts.cubedwater.com - my bloggings about Yii
0

#9 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,902
  • Joined: 04-October 08
  • Location:DC, USA

Posted 02 March 2010 - 07:36 PM

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

#10 User is offline   jonah 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 733
  • Joined: 27-November 08
  • Location:California (US)

Posted 02 March 2010 - 08:21 PM

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
http://php-thoughts.cubedwater.com - my bloggings about Yii
0

#11 User is offline   rohit 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 71
  • Joined: 08-July 09
  • Location:India

Posted 02 March 2010 - 10:25 PM

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!
0

#12 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,902
  • Joined: 04-October 08
  • Location:DC, USA

Posted 02 March 2010 - 11:35 PM

@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.
0

#13 User is offline   rohit 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 71
  • Joined: 08-July 09
  • Location:India

Posted 03 March 2010 - 01:28 AM

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?
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