@@ -38,6 +38,8 @@ protected function _ajax($method,$url,$responseElement="",$parameters=[]) {
3838 $ retour .="var self=this; \n" ;
3939 if ($ hasLoader ===true && JString::isNotNull ($ responseElement )){
4040 $ this ->addLoading ($ retour , $ responseElement ,$ ajaxLoader );
41+ }elseif ($ hasLoader ==="internal " ){
42+ $ retour .="\n$(this).addClass('loading'); " ;
4143 }
4244 $ ajaxParameters =["url " =>"url " ,"method " =>"' " .\strtoupper ($ method )."' " ];
4345
@@ -51,7 +53,7 @@ protected function _ajax($method,$url,$responseElement="",$parameters=[]) {
5153 }
5254 $ this ->createAjaxParameters ($ ajaxParameters , $ parameters );
5355 $ retour .="$.ajax({ " .$ this ->implodeAjaxParameters ($ ajaxParameters )."}).done(function( data, textStatus, jqXHR ) { \n" ;
54- $ retour .=$ this ->_getOnAjaxDone ($ responseElement , $ jqueryDone ,$ ajaxTransition ,$ jsCallback )."}); \n" ;
56+ $ retour .=$ this ->_getOnAjaxDone ($ responseElement , $ jqueryDone ,$ ajaxTransition ,$ jsCallback, $ hasLoader )."}); \n" ;
5557 $ retour =$ this ->_addJsCondition ($ jsCondition ,$ retour );
5658 if ($ immediatly )
5759 $ this ->jquery_code_for_compile []=$ retour ;
@@ -100,7 +102,7 @@ protected function _getAjaxUrl($url,$attr){
100102 return $ retour ;
101103 }
102104
103- protected function _getOnAjaxDone ($ responseElement ,$ jqueryDone ,$ ajaxTransition ,$ jsCallback ){
105+ protected function _getOnAjaxDone ($ responseElement ,$ jqueryDone ,$ ajaxTransition ,$ jsCallback, $ hasLoader = false ){
104106 $ retour ="" ;$ call =null ;
105107 if (JString::isNotNull ($ responseElement )) {
106108 if (isset ($ ajaxTransition )){
@@ -113,6 +115,9 @@ protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$
113115 else
114116 $ retour ="\t{$ responseElement }. {$ jqueryDone }( data ); \n" ;
115117 }
118+ if ($ hasLoader ==="internal " ){
119+ $ retour .="\n$(self).removeClass('loading'); " ;
120+ }
116121 $ retour .="\t" .$ jsCallback ."\n" ;
117122 return $ retour ;
118123 }
@@ -480,14 +485,16 @@ private function _postForm($url, $form, $responseElement, $parameters=[]) {
480485 $ retour .="var self=this; \n" ;
481486 if ($ hasLoader ===true ){
482487 $ this ->addLoading ($ retour , $ responseElement ,$ ajaxLoader );
488+ }elseif ($ hasLoader ==="internal " ){
489+ $ retour .="\n$(this).addClass('loading'); " ;
483490 }
484491 $ ajaxParameters =["url " =>"url " ,"method " =>"'POST' " ,"data " =>"params " ,"async " =>$ async ];
485492 if (isset ($ headers )){
486493 $ ajaxParameters ["headers " ]=$ headers ;
487494 }
488495 $ this ->createAjaxParameters ($ ajaxParameters , $ parameters );
489496 $ retour .="$.ajax({ " .$ this ->implodeAjaxParameters ($ ajaxParameters )."}).done(function( data ) { \n" ;
490- $ retour .=$ this ->_getOnAjaxDone ($ responseElement , $ jqueryDone ,$ ajaxTransition ,$ jsCallback )."}); \n" ;
497+ $ retour .=$ this ->_getOnAjaxDone ($ responseElement , $ jqueryDone ,$ ajaxTransition ,$ jsCallback, $ hasLoader )."}); \n" ;
491498
492499 if ($ validation ) {
493500 $ retour ="$('# " .$ form ."').validate({submitHandler: function(form) {
0 commit comments