Search code examples
codeigniterjquery-ui-tabs

How do I create tabbed UI in codeIgniter with jquery UI?


am using codeIgniter to develop a web app and for my UI, I want to use jQuery-UI-Tabs. I am locked down as to how to get my views to show up in their respective tabs. Any help?


Solution

  • It depends on how you want to do it.

    If you want to pre-load all the views separately, and have it there, then here's how:

    In CodeIgniter:

    $views['pageOne'] = $this->load->view('view_name', $data, true);
    $views['pageTwo'] = $this->load->view('view_name2', $data, true);
    

    in jQuery UI Tabs:

    <div id="tabs">
        <ul>
            <li><a href="#tabs-1">Page 1</a></li>
            <li><a href="#tabs-2">Page 2</a></li>
        </ul>
        <div id="tabs-1">
            <?php echo $pageOne;?>
        </div>
        <div id="tabs-2">
            <?php echo $pageTwo;?>
        </div>
    
    </div>
    

    Another way would be the Ajax way.

    <div id="tabs">
        <ul>
            <li><a href="link-to-controller">Page 1</a></li>
            <li><a href="link-to-controller">Page 2</a></li>
        </ul>
    </div>