使用jquery选项卡时显示两次 [英] header shown two times when using jquery tabs

查看:144
本文介绍了使用jquery选项卡时显示两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的错误(我使用 codeigniter ),标题和jquery标签显示两次:

I got a weird error (i use codeigniter), the header and jquery tabs is shown two times :

这是我的 header_v 是jquery标签的位置:

This is my header_v, the place for the jquery tabs :

<script>
  $(function() {
    $( "#datepicker" ).datepicker();
  });

  $(function() {
    $( "#tabs" ).tabs();
  });
</script>

<div id="header"><h1>HEADER</h1></div>
    <div id="tabs">
        <ul>
            <li><a href="umat">Daftar Umat</a></li>
            <li><a href="#">Daftar Pengurus</a></li>
            <li><a href="absensi">Absensi</a></li>
        </ul>
    </div>

这是 umat_v 点击第一个标签时加载:

This is umat_v, the view that will loaded when the first tab is clicked :

<body>
    <div id="form_search">
        <?php echo form_open('backend/index') ?>
            <p>
            Kelas :
            <?php echo form_dropdown('ddl_kelas1', $list_kelas, 'id="ddl_kelas1"');?> -
            <?php echo form_dropdown('ddl_kelas2', $list_kelas, 'id="ddl_kelas2"');?>
            </p>
            <p>
            Nama : <?php echo form_input('txt_nama');?>
            Alamat : <?php echo form_input('txt_alamat');?>
            Tanggal Lahir : <input type="text" id="datepicker" />
            </p>
            <?php echo form_submit('btn_search', 'Search');?>
        <?php echo form_close(); ?>
    </div>
    <div>
        <?php echo $table ?>
        <?php echo $pagination ?>
    </div>
</body>

这是控制器加载这些视图:

public function umat() {
    $this->load->view('template/header_v');
    //check authorization
    if(!isset($_SESSION['username']))
        redirect('backend');

    //pagination
    $config['base_url'] = site_url('/backend/umat/');
    $config['total_rows'] = $this->backend_m->count_umat();
    $config['per_page'] = 10; 
    $config['uri_segment'] = 3;
    $config['full_tag_open'] = '<div id="pagination">';
    $config['full_tag_close'] = '</div>';

    $this->pagination->initialize($config); 

    $data['pagination'] = $this->pagination->create_links();

    //table     
    $data_umat = $this->backend_m->get_umat();

    $this->table->set_heading(
        'No',
        'Nama',
        'Kelas',
        'Alamat',
        'Sekolah',
        'Nomor Telepon',
        'Keterangan'        
    );

    $no = 1;
    foreach($data_umat as $list_temp) 
    {
        $this->table->add_row(
            $no++,
            $list_temp->nama,
            $list_temp->kelas,
            $list_temp->alamat,
            $list_temp->sekolah,
            $list_temp->no_tlpn,
            $list_temp->keterangan
        );
    }


    $data_kelas = $this->backend_m->get_kelas();

    $data['list_kelas'][0] = 'Pilih Kelas';

    foreach($data_kelas as $row)
    {
        $data['list_kelas'][$row->kelas_id] = $row->kelas;
    }

    $data['table'] = $this->table->generate();

    $this->load->view('backend/umat_v', $data);
}

为什么我的标题/ header_v 总是加载2次?感谢:D

Why my header/header_v always loaded 2 times? Thanks :D

推荐答案

在您的控制器中,您的函数的开头有这行:

In your controller you have this line right at the beginning of your function:

$this->load->view('template/header_v');

就我所见,您正在加载模板,包括标题和

So as far as I can see, you are loading the template again, including the header and (as you can probably see in your screenshot) the list items, too.

因此,我认为你需要指定另一个模板。

Therefore I think you need to specify another template to be used.

要在评论中有更多空间进行讨论,请修改:

To have more room for the ongoing discussion in the comments, here an edit:

需要两个不同的控制器,一个用于页面,一个用于每个选项卡。在主控制器中,用

You need two different controllers, one for the page and one for each tab. In the main controller you display your header with

$this->load->view('template/header_v');

但是在每个选项卡中,您不能再包括标题了!由于您在列表项中包含href,jQuery Tabs将通过AJAX加载内容。

But in each tab you must not include the header anymore! Since you included hrefs in the list items, jQuery Tabs will load the content via AJAX.

这篇关于使用jquery选项卡时显示两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆