Dear all,
I have a problem with CPagination with Tabs .
I have 2 tabs call Tab1 and Tab2 , each of which has it own pagination.
Default active Tab is Tab1 .
The problem is : When user is on Tab2, and click to a “Page #5 ” button ( I don’t use ajax), the page is reloaded and the active Tab is Tab1 while expected active Tabs should be Tab2 .
Can anyone has an idea ?
alirz23
(Alirz23)
August 13, 2012, 8:33am
2
I think ajax will be perfect solution for your problem without ajax will be hard
Currently, I have to do without ajax because we have to allow user to share the current url .
Any idea, even it is hard to implement.
I
ramabarca
(Ramabarca)
August 13, 2012, 10:29am
4
Maybe appending the html id attribute to pagination links, like <paginationLink>#Tab2
HaCogini
(Ha)
August 13, 2012, 11:05am
5
Hey, how can we add this ?
Pls let me know, thank you
ramabarca
(Ramabarca)
August 13, 2012, 11:45am
6
for testing purposes, to see if it works, directly on the url input of your browser
HaCogini
(Ha)
August 13, 2012, 11:50am
7
I mean in the production job.
In testing , I can anchor ( get hash) to get the page , and active the Tab. that should work.
Can you let me know how to append #sth in the Yii Pagination Link/
Thank you
ramabarca
(Ramabarca)
August 13, 2012, 1:00pm
8
You could probably extend CPagination class overriding createPageUrl method:
// protected/components/MyPagination.php
class MyPagination extends CPagination {
public function createPageUrl($controller,$page)
{
$params=$this->params===null ? $_GET : $this->params;
if($page>0) // page 0 is the default
$params[$this->pageVar]=$page+1;
else
unset($params[$this->pageVar]);
// aditional anchor (hash) parameter
$params['#'] = 'Tab2';
return $controller->createUrl($this->route,$params);
}
}
hope it helps!
mdomba
(Maurizio Domba Cerin)
August 16, 2012, 7:56am
10
[color="#008000 "]NOTE_ moved to proper section (General Discussion for Yii 1.1.x instead of Tips, Snippets and Tutorials)[/color]