Tom
Tom

Reputation: 173

Pagination link and tabs

My page with paginated nested tabs.

I am trying to get "nested" jQuery tabs that refer to categories which contain projects to work with CodeIgniter pagination. I am trying to paginate projects.

I am up against a basic problem. Clicking on the pagination links always takes the user back to the default selected category tab. You will see what I mean if you go to the site; the pagination works so far as it selects the right block of records, but it shows the wrong category. If you click back to right category, the right block of records are there.

I have fiddled with jQuery to make a script that grabs information from the pagination links to select the right category tab but then realised a simple and obvious problem.

The pagination works by revisiting the controller and reshowing the view which renders useless any remedial jQuery script. Remedial jQuery depends on a 'return false' line, which kills the pagination.

The obvious conclusion is that I need to tweak the main tabs jQuery going into the view, as it were, rather than via a remedial script. The overall process I have in mind is:

  1. first category tab selected (as it should be)
  2. click on another category tab and click on that tab's project pagination links
  3. this cycles through the controller and reshows the view and somehow passes information about the selected category to jQuery so allowing the correct category tab to be selected

Apologies in advance for kind of stating the obvious, but I would appreciate help achieving this.

How can I achieve it?

Upvotes: 0

Views: 1415

Answers (1)

toopay
toopay

Reputation: 1635

Actually, you can provide a function, to act as "section provider" for your pagination section, suppose you have something like this in your view...

<div id="base_pagination"><!-- Heres you outputing the content and pagination link --></div>

And then, you can create a function to serve (only) AJAX request and outputing a pagination section...

function get_pagination_content($id)
{
    if($this->input->is_ajax_request())
    {
        // Proccess the request...
        // ...
        // Outputing the pagination section as replacement to old one
        echo '<div id="base_pagination"><!-- Heres you outputing the new content and new pagination link --></div>';
        // You always can use $this->load->view('some_view',$data) too.
    }
    else
    {
        // They not came from AJAx request, so give an error
        show_404();
    }
} 

Upvotes: 1

Related Questions