Skip to content

Commit 7ff1b88

Browse files
committed
jqueryDone fixed
1 parent b7fff6d commit 7ff1b88

File tree

5 files changed

+44
-24
lines changed

5 files changed

+44
-24
lines changed

Ajax/JsUtils.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ public function config($config=NULL) {
166166
public function __construct($params=array(),$injected=NULL) {
167167
$defaults=array (
168168
'driver' => 'Jquery',
169-
'debug' => true
169+
'debug' => true,
170+
'defer' => false
170171
);
171172
foreach ( $defaults as $key => $val ) {
172173
if (isset($params[$key])===false || $params[$key]==="") {

Ajax/common/traits/JsUtilsAjaxTrait.php

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
namespace Ajax\common\traits;
44

55
use Ajax\service\JArray;
6+
use Ajax\JsUtils;
67

78
/**
89
* @author jc
9-
* @property Ajax\JsUtils $js
10+
* @property JsUtils $js
1011
*/
1112
trait JsUtilsAjaxTrait {
1213

@@ -21,9 +22,10 @@ public function setAjaxLoader($loader) {
2122
* @param string $responseElement selector of the HTML element displaying the answer
2223
* @param string $jsCallback javascript code to execute after the request
2324
* @param boolean $hasLoader true for showing ajax loader. default : true
25+
* @param string $jqueryDone the jquery function call on ajax data. default:html
2426
*/
25-
public function get($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true) {
26-
return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,true);
27+
public function get($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html") {
28+
return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,true);
2729
}
2830

2931
/**
@@ -68,7 +70,7 @@ public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL
6870
* @param string $jsCallback javascript code to execute after the request
6971
*/
7072
public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL) {
71-
return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, NULL, true);
73+
return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, NULL,true);
7274
}
7375

7476
/**
@@ -78,6 +80,7 @@ public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsC
7880
* @param string $params JSON parameters
7981
* @param string $method Method used
8082
* @param string $jsCallback javascript code to execute after the request
83+
* @param string $jqueryDone the jquery function call on ajax data. default:html
8184
*/
8285
public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL) {
8386
return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, NULL, false);
@@ -102,9 +105,10 @@ public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=arra
102105
* @param string $responseElement selector of the HTML element displaying the answer
103106
* @param string $jsCallback javascript code to execute after the request
104107
* @param string $attr the html attribute added to the request
108+
* @param string $jqueryDone the jquery function call on ajax data. default:html
105109
*/
106-
public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id") {
107-
return $this->js->_get($url, $params, $responseElement, $jsCallback, $attr, false);
110+
public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id",$jqueryDone="html") {
111+
return $this->js->_get($url, $params, $responseElement, $jsCallback, $attr, false,$jqueryDone);
108112
}
109113

110114
/**
@@ -114,7 +118,7 @@ public function getDeferred($url, $responseElement="", $params="{}", $jsCallback
114118
* @param string $element
115119
* @param string $url The url of the request
116120
* @param string $responseElement The selector of the HTML element displaying the answer
117-
* @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true)
121+
* @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html")
118122
*/
119123
public function getOn($event, $element, $url, $responseElement="", $parameters=array()) {
120124
$params=JArray::getDefaultValue($parameters, "params", "{}");
@@ -127,7 +131,7 @@ public function getOn($event, $element, $url, $responseElement="", $parameters=a
127131
* @param string $element
128132
* @param string $url The url of the request
129133
* @param string $responseElement The selector of the HTML element displaying the answer
130-
* @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true)
134+
* @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html")
131135
*/
132136
public function getOnClick($element, $url, $responseElement="", $parameters=array()) {
133137
return $this->getOn("click", $element, $url, $responseElement, $parameters);
@@ -140,9 +144,10 @@ public function getOnClick($element, $url, $responseElement="", $parameters=arra
140144
* @param string $responseElement selector of the HTML element displaying the answer
141145
* @param string $jsCallback javascript code to execute after the request
142146
* @param boolean $hasLoader true for showing ajax loader. default : true
147+
* @param string $jqueryDone the jquery function call on ajax data. default:html
143148
*/
144-
public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true) {
145-
return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,true);
149+
public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html") {
150+
return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,true);
146151
}
147152

148153
/**
@@ -154,9 +159,10 @@ public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$
154159
* @param string $responseElement selector of the HTML element displaying the answer
155160
* @param string $jsCallback javascript code to execute after the request
156161
* @param boolean $hasLoader true for showing ajax loader. default : true
162+
* @param string $jqueryDone the jquery function call on ajax data. default:html
157163
*/
158-
public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true) {
159-
return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,false);
164+
public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true,$jqueryDone="html") {
165+
return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,$jqueryDone,false);
160166
}
161167

162168
/**
@@ -167,7 +173,7 @@ public function postDeferred($url, $responseElement="", $params="{}", $jsCallbac
167173
* @param string $url The url of the request
168174
* @param string $params The parameters to send
169175
* @param string $responseElement selector of the HTML element displaying the answer
170-
* @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true)
176+
* @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html")
171177
*/
172178
public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) {
173179
return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters);
@@ -180,7 +186,7 @@ public function postOn($event, $element, $url, $params="{}", $responseElement=""
180186
* @param string $url The url of the request
181187
* @param string $params The parameters to send
182188
* @param string $responseElement selector of the HTML element displaying the answer
183-
* @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true)
189+
* @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html")
184190
*/
185191
public function postOnClick($element, $url, $params="{}", $responseElement="", $parameters=array()) {
186192
return $this->postOn("click", $element, $url, $params, $responseElement, $parameters);
@@ -193,9 +199,10 @@ public function postOnClick($element, $url, $params="{}", $responseElement="", $
193199
* @param string $responseElement selector of the HTML element displaying the answer
194200
* @param string $jsCallback javascript code to execute after the request
195201
* @param boolean $hasLoader true for showing ajax loader. default : true
202+
* @param string $jqueryDone the jquery function call on ajax data. default:html
196203
*/
197-
public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$hasLoader=true) {
198-
return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader,true);
204+
public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$hasLoader=true,$jqueryDone="html") {
205+
return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader,$jqueryDone,true);
199206
}
200207

201208
/**
@@ -207,9 +214,10 @@ public function postForm($url, $form, $responseElement, $validation=false, $jsCa
207214
* @param string $jsCallback javascript code to execute after the request
208215
* @param string $attr the html attribute added to the request
209216
* @param boolean $hasLoader true for showing ajax loader. default : true
217+
* @param string $jqueryDone the jquery function call on ajax data. default:html
210218
*/
211-
public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true) {
212-
return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader,false);
219+
public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true,$jqueryDone="html") {
220+
return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader,$jqueryDone,false);
213221
}
214222

215223
/**
@@ -220,7 +228,7 @@ public function postFormDeferred($url, $form, $responseElement, $validation=fals
220228
* @param string $url
221229
* @param string $form
222230
* @param string $responseElement selector of the HTML element displaying the answer
223-
* @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true)
231+
* @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html")
224232
*/
225233
public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) {
226234
return $this->js->_postFormOn($event,$element, $url, $form, $responseElement, $parameters);
@@ -233,7 +241,7 @@ public function postFormOn($event, $element, $url, $form, $responseElement="", $
233241
* @param string $url
234242
* @param string $form
235243
* @param string $responseElement selector of the HTML element displaying the answer
236-
* @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true)
244+
* @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html")
237245
*/
238246
public function postFormOnClick($element, $url, $form, $responseElement="", $parameters=array()) {
239247
return $this->postFormOn("click", $element, $url, $form, $responseElement, $parameters);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Ajax\semantc\html\base;
4+
5+
interface FieldAsFormField {
6+
public function toFormField();
7+
}

Ajax/semantic/widgets/datatable/DataTable.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public function compile(JsUtils $js=NULL,&$view=NULL){
6969
if(isset($this->_compileParts))
7070
$table->setCompileParts($this->_compileParts);
7171
if(isset($this->_searchField) && isset($js)){
72+
$this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
7273
}
7374

7475
$this->_generateContent($table);
@@ -122,6 +123,7 @@ private function _generatePagination($table){
122123
$menu->floatRight();
123124
$menu->setActiveItem($this->_pagination->getPage()-1);
124125
$footer->setValues($menu);
126+
$menu->postOnClick($this->_urls,"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
125127
}
126128

127129
protected function _setToolbarPosition($table,$captions=NULL){

Ajax/service/AjaxCall.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public function compile(JsUtils $js=null) {
2323
$validation=false;
2424
$stopPropagation=true;
2525
$preventDefault=true;
26+
$jqueryDone="html";
27+
$hasLoader=true;
2628
extract($this->parameters);
2729
if ($preventDefault===true) {
2830
$result.="\nevent.preventDefault();\n";
@@ -32,13 +34,13 @@ public function compile(JsUtils $js=null) {
3234
}
3335
switch($this->method) {
3436
case "get":
35-
$result.=$js->getDeferred($url, $responseElement, $params, $callback, $attr);
37+
$result.=$js->getDeferred($url, $responseElement, $params, $callback, $attr,$jqueryDone);
3638
break;
3739
case "post":
38-
$result.=$js->postDeferred($url, $responseElement, $params, $callback, $attr);
40+
$result.=$js->postDeferred($url, $responseElement, $params, $callback, $attr,$hasLoader,$jqueryDone);
3941
break;
4042
case "postForm":
41-
$result.=$js->postFormDeferred($url, $form, $responseElement, $validation, $callback, $attr);
43+
$result.=$js->postFormDeferred($url, $form, $responseElement, $validation, $callback, $attr,$hasLoader,$jqueryDone);
4244
break;
4345
}
4446
return $result;

0 commit comments

Comments
 (0)