Welcome Guest, Not a member yet? Register   Sign In
View issue displays the page within the page.
#1

[eluser]debow[/eluser]
To start with I'm using Shawn McCool's layout template as a starting point. This code worked on a diff project but now I'm trying to use SparksActive Record along with Shawns layout and get the funky issue of my results showing but the whole page displays again under my results. I'm trying to use a ajax table so I can use pagination without changing the url. Any help or suggestions are more then welcomed.

controller = fs.php Part of the issue seems to be with the echo $_html and the div in the below view.
Code:
<?php
class Fs extends MY_Controller {

    function display_fs(){
    }

    function ajax_display_fs(){
        $start_row = $this->uri->segment(3);
        $per_page=1;
        
        if (trim($start_row) == '') {
            $start_row = 0;
        }
        
        $total_rows = $this->view_data['num_rows'] = Fsystem::count();
        
        $this->load->library('pagination');
        $config['base_url'] = base_url() . 'fs/ajax_display_fs';
        $config['total_rows'] = $total_rows;
        $config['per_page'] = $per_page;
        $config['full_tag_open'] = '<p class="things_pagination">';
        $config['full_tag_close'] = '</p>';
        
        $this->pagination->initialize($config);
        $this->view_data['pagination'] = $this->pagination->create_links();
        $this->view_data['commands'] = Fsystem::find("all", array("limit"=>$per_page, "offset"=>$start_row));
        $this->session->set_userdata('table_start_row', $start_row);

        $_html = $this->load->view('fs/display_table', $this->view_data, TRUE);
        
        echo $_html;
    }


view = display_fs.php The isssue seems to be with the <div id="things_table">. I remove that that page is fine but table doesn't show.
Code:
<div id="things_table"> </div>

</div>
&lt;!-- ENDS content --&gt;
[removed]
    
    $(document).ready(function(){
    
        $.post("&lt;?= base_url(); ?&gt;fs/ajax_display_fs/&lt;?= $this->session->userdata('table_start_row'); ?&gt;", { }, function(data) {        
            $("div#things_table").html(data);        
        });
      
        $("p.things_pagination a").live("click", function(){      
            var this_url = $(this).attr("href");    
            $.post(this_url, { }, function(data) {        
                $("div#things_table").html(data);        
            });
            return false;
        });
    
    });
[removed]


view=display_table.php
Code:
just my table info.......


Shawns my_controller.php
Code:
&lt;?php

class MY_Controller extends CI_Controller
{
    var $user = FALSE;

    // layout / autoview functionality
    protected $layout_view = 'application';
    protected $content_view = '';
    
    //data sent to content view
    protected $view_data = array();

    function __construct()
    {
        parent::__construct();

        $this->user = $this->session->userdata('user_id') ? User::find($this->session->userdata('user_id')) : FALSE;
    }

    public function _output($output)
    {
        // set the default content view
        if($this->content_view !== FALSE && empty($this->content_view)) $this->content_view = $this->router->class . '/' . $this->router->method;

        // render the content view
        $yield = file_exists(APPPATH . 'views/' . $this->content_view . EXT) ? $this->load->view($this->content_view, $this->view_data, TRUE) : FALSE;

        // render the layout
        if($this->layout_view)
            echo $this->load->view('layouts/' . $this->layout_view, array('yield' => $yield), TRUE);
        else
            echo $yield;

        // output CI profiler information
        echo $output;
    }
}




Theme © iAndrew 2016 - Forum software by © MyBB