Hello, i'm new here and i'm new using grocery crud (such amazing crud!!).
My problem is:
I'm using codeigniter, i don't like full page refreshes so i'm loading my crud table inside a div using ajax, but in the first load, buttons doesn't show correctly, it looks like this:
... but after several reloads (using F5, i'm captured the hash to request the required controller from server on document.ready), it shows correctly:
My internal code (por "parametro" controller, showed in the images) is:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Parametro extends CI_Controller { public function __construct(){ parent::__construct(); $this->load->library('grocery_CRUD'); } public function index(){ if(!$this->verificarUserDataSesion()) { header('Location: ' . base_url()); die(); } $crud = new grocery_CRUD(); $this->config->load('grocery_crud'); $crud->set_theme('flexigrid'); $crud->set_subject('Parametro del Sistema'); $crud->set_table('parametros'); $crud->columns('idpara','nombre','valor','login','tipo'); $crud->display_as('idpara','Codigo'); $crud->set_relation('login','usuario','login'); $crud->display_as('login','Usuario'); $crud->field_type('tipo','dropdown', array('U' => 'Usuario', 'S' => 'Sistema')); $contenido= new stdClass(); $data= new stdClass(); $data=$crud->render(); $data->titulo= 'Gestión de Parametros del Sistema'; $this->load->view('v_crud',$data); } private function verificarUserDataSesion(){ if(isset($this->session->userdata['logged_in'])){ return true; }else{ return false; } } } ?>
Im loading it inside a div (with buttons) with this javascript (using jquery) code:
$("#sis-usua").click(function(e) { simple_load("usuario"); }); $("#sis-agen").click(function(e) { simple_load("agencia"); }); $("#sis-para").click(function(e) { simple_load("parametro"); }); $("#par-marc").click(function(e) { simple_load("marca"); }); $("#par-unid").click(function(e) { simple_load("unidad"); }); $("#par-clie").click(function(e) { simple_load("cliente"); }); $("#par-prov").click(function(e) { simple_load("proveedor"); }); function simple_load(controller){ $("#contenido") .html("<center><img src=\"<?=base_url()?>img/loader-small.GIF\" style=\"margin-top:100px;\"></center>") .load("<?=base_url()?>" + controller); }
My problem is in the first image, it's not showing correctly, i have headaches trying to figure it out, also i have some questions:
- I can preload js and css files in header and not calling it every time i load a crud table?
- Why new styles are not applying when i refresh (or reload) ti the crud table after i modify the original flexigrid.css file, it's an ajax issue?
Please help me and sorry if my english is bad.