2015-04-26 64 views
1

$ data ['insertion'] ='true'; $ this-> load-> view('header'); $ this-> load-> view('clase_view',$ data);我正在試圖展示DIV內容只能讓後插入並返回到主界面,然後顯示出他div的內容,我很usign isset但verifynew方法插入後狀態並沒有工作插入後顯示div內容codeigniter

</head> 
    <body>  
     <nav class="navbar navbar-default navbar-static-top" role="navigation"> 
      <div class="container"> 
      <ul class="nav navbar-nav"> 
       <li class="active"><a href=<?php echo base_url('index.php/clase')?>>Clases</a></li> 
       <li><a href="office">Despachos</a></li> 
       <li><a href="clase">Otros Servicios</a></li> 
       <li><a href="clase">Administracion de usuario</a></li> 
      </ul> 
      </div> 
     </nav> 
     <div class="container"> 
      <div class="row"> 
        <h1><strong>Editor de Clases</strong></h1> 
        <?php 
         if(isset($insertion)){ 
          echo "<div>Show after insertion</div>"; 
         } 
        ?> 
       </div> 
       <div class = "row"> 
        <p> 
        <a href="clase/create" class="btn btn-success">Nuevo</a> 
        <p> 
      </div> 

      <div class="row"> 
       <table class="table table-striped table-bordered"> 
        <thead> 
        <tr> 
         <th>Nombre</th> 
         <th>Información</th> 
         <th>Opciones</th> 
         </tr> 
        </thead> 
        <tbody> 
        <?php foreach($clases as $clase_item){ 
         echo "<tr>"; 
          echo "<td>".$clase_item->nombre."</td>"; 
          echo "<td>".$clase_item->info."</td>"; 
          echo "<td align='center'>"; 
          echo '<a class="btn btn-success" href="clase/update/'.$clase_item->nombre.'/'.$clase_item->info.'">Editar</a>'; 
          echo '<a class="btn btn-danger" href="clase/delete/'.$clase_item->nombre.'">Borrar</a>'; 
          echo "</td>"; 
         echo "</tr>"; 
        } ?> 
      </tbody> 
       </table> 
      </div> 

      <!--Modal para crear nueva clase--> 
      <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
       <div class="modal-dialog"> 
       <div class="modal-content"> 
        <div class="modal-header"> 
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> 
        <h4 class="modal-title" id="myModalLabel">Crear nueva clase</h4> 
        </div> 
        <div class="modal-body"> 

        </div> 
       </div> 
       </div> 
      </div> 

      <!--Fin modal crear--> 
    </body> 
</html> 

我創建inserion變量,但div的內容不顯示

function verifyNew(){ 
     $this->load->library('form_validation'); 
     $this->form_validation->set_rules('name', 'Nombre', 'trim|max_length[20]|required|callback_not_repeated'); 
     $this->form_validation->set_rules('info', 'Informacion', 'max_length[256]'); 

     if($this->form_validation->run() == FALSE){ 
     $this->load->view('header'); 
     $this->load->view('clase_create_view'); 
     } 
     else{ 
      if($this->input->post('info')){ 
      $this->insert2($this->input->post('name'),$this->input->post('info')); 
      } 
      else{ 
      $this->insert1($this->input->post('name')); 
      } 
      $data['insertion'] = 'true'; 
      $this->load->view('header'); 
      $this->load->view('clase_view',$data); 
     } 
    } 

回答

1

Tiene que pasar $ data a la vista。

您必須將$ data傳遞給視圖。

$data['insertion'] = 'true'; 
$this->load->view('header'); 
$this->load->view('clase_create_view', $data); 
+0

我已經編輯了我的帖子,但是這個路徑也不起作用 – AFS

+0

這是一樣的看法嗎? Puedo ver dos vistas:'clase_create_view'y'clase_create'。 –

+0

問題解決了謝謝 – AFS