Hi I am using Grocery CRUD with HMVC and I am facing some strange problem with that.
class Source extends MX_Controller
{
function __construct() {
parent::__construct();
}
function index(){
try{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('source');
$crud->set_subject('Source');
$output = $crud->render();
$data['css_files'] = $output->css_files;
$data['js_files'] = $output->js_files;
$data['output'] = $output->output;
$this->template->title('Source')
->set_layout('default')
->build('example', $data );
}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}
}
And in source table I have only one column "name" and other is id with auto increment and primary key.
When I add or insert data, it add multiple data in table some time 3 or 4 times duplicate data.
I am also using template library.
This is strange issue I am facing first time with this Grocery Crud, can any one help me out to solve this.
I do have same issue with grocerycrud data get inserted multiple time, and I solve this issue by adding following code to the js file.
I was using datatable theme and in that the file was grocery_crud\themes\datatables\js\datatables-add.js
$('#save-and-go-back-button').click(function(event){
event.stopImmediatePropagation();
save_and_close = true;
$('#crudForm').trigger('submit');
});
$('#crudForm').submit(function(event){
event.stopImmediatePropagation();
$(this).ajaxSubmit({
url: validation_url,
.......
we need to add "event.stopImmediatePropagation();" after the click and submit events.
This will help to stop multiple dulplicate insert.