From b691dd4bca4cddfbf63f7b8ef450f00c6df2c078 Mon Sep 17 00:00:00 2001 From: faoliva Date: Thu, 30 Apr 2015 17:12:19 -0300 Subject: [PATCH 1/3] prevent first ajax submition Since i can render a zfTable in first request of a page, its necesary to prevent the first ajax request. This is my code: PHP Contoller: //first request public function listarAction() { $urlTabla = "/abm/ajax/rol" // $tabla = $this->renderTabla() return [ 'url' => $urlTabla, 'tabla' => $tabla ]; } //ajax request public function ajaxAction() { return $this->htmlResponse$this->renderTabla()); } //return ZfTable rendered protected function renderTabla(){ /* @var $tabla \Abm\Table\AbmTabla */ $tabla = $this->getServiceLocator()->get('abmTabla'); //abmTabla extends ZfTable\AbstractTable $tabla->setHeaders(....); //seting headers $tabla->setConfig(.....); //setting config $tabla->setAdapter($this->getDbAdapter()) ->setSource($qb) //seting query ->setParamAdapter($this->getRequest()->getPost()); return $tabla->render(); } MY JS tabla.zfTable(url, { onInit: function() { return false; }, complete: function(){ console.log('complete'); $('.form-inline').removeClass('form-inline') .addClass('form') .find('.filter').addClass('input-sm'); } }); --- src/ZfTable/Public/js/zf-table.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ZfTable/Public/js/zf-table.js b/src/ZfTable/Public/js/zf-table.js index af5d224..9ad7d4f 100644 --- a/src/ZfTable/Public/js/zf-table.js +++ b/src/ZfTable/Public/js/zf-table.js @@ -41,8 +41,10 @@ } function init($obj) { - options.onInit(); - ajax($obj); + var rta = options.onInit(); + if (rta !== false){ + ajax($obj); + } } function ajax($obj) { $obj.prepend('
'); @@ -162,4 +164,4 @@ }); }; -})(jQuery); \ No newline at end of file +})(jQuery); From 6fd2ac2f9e4054562efe40a678bc1745b7056ab0 Mon Sep 17 00:00:00 2001 From: faoliva Date: Thu, 30 Apr 2015 17:31:20 -0300 Subject: [PATCH 2/3] Update zf-table.js --- src/ZfTable/Public/js/zf-table.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ZfTable/Public/js/zf-table.js b/src/ZfTable/Public/js/zf-table.js index 9ad7d4f..bf59869 100644 --- a/src/ZfTable/Public/js/zf-table.js +++ b/src/ZfTable/Public/js/zf-table.js @@ -44,7 +44,11 @@ var rta = options.onInit(); if (rta !== false){ ajax($obj); - } + } else { + initialized = true; + initNavigation($obj); + $obj.find('.processing').hide(); + } } function ajax($obj) { $obj.prepend('
'); From f2f64cb44ed3ab53ee2a04076f2ede4598349135 Mon Sep 17 00:00:00 2001 From: faoliva Date: Thu, 30 Apr 2015 17:38:50 -0300 Subject: [PATCH 3/3] Update zf-table.js --- src/ZfTable/Public/js/zf-table.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ZfTable/Public/js/zf-table.js b/src/ZfTable/Public/js/zf-table.js index bf59869..33a96b5 100644 --- a/src/ZfTable/Public/js/zf-table.js +++ b/src/ZfTable/Public/js/zf-table.js @@ -45,10 +45,10 @@ if (rta !== false){ ajax($obj); } else { - initialized = true; - initNavigation($obj); + initialized = true; + initNavigation($obj); $obj.find('.processing').hide(); - } + } } function ajax($obj) { $obj.prepend('
');