@@ -602,7 +602,7 @@ public function getOnClick($element, $url, $responseElement = '', $parameters =
602
602
* @param string $responseElement
603
603
* the target of the ajax request (data-target attribute of the element is used if responseElement is omited)
604
604
* @param array $parameters
605
- * default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true,"before"=>null)
605
+ * default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true,"before"=>null,"listenerOn"=>false )
606
606
* @return $this
607
607
*/
608
608
public function getHref ($ element , $ responseElement = "" , $ parameters = array ()) {
@@ -626,7 +626,7 @@ public function getHref($element, $responseElement = "", $parameters = array())
626
626
* @param string $responseElement
627
627
* the target of the ajax request (data-target attribute of the element is used if responseElement is omited)
628
628
* @param array $parameters
629
- * default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true,"before"=>null)
629
+ * default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true,"before"=>null,"listenerOn"=>false )
630
630
* @return $this
631
631
*/
632
632
public function postHref ($ element , $ responseElement = "" , $ parameters = array ()) {
@@ -642,6 +642,37 @@ public function postHref($element, $responseElement = "", $parameters = array())
642
642
return $ this ->postOnClick ($ element , '' , '{} ' , $ responseElement , $ parameters );
643
643
}
644
644
645
+ /**
646
+ * Uses a form action to make an ajax post request
647
+ *
648
+ * @param string $element
649
+ * a form submit selector
650
+ * @param string $formId
651
+ * the form identifier
652
+ * @param string $responseElement
653
+ * the target of the ajax request (data-target attribute of the element is used if responseElement is omited)
654
+ * @param array $parameters
655
+ * default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true,"before"=>null,"listenerOn"=>false)
656
+ * @return $this
657
+ */
658
+ public function postFormAction ($ element , $ formId = "" , $ responseElement = "" , $ parameters = array ()) {
659
+ $ parameters ['attr ' ] = 'action ' ;
660
+ if (JString::isNull ($ responseElement )) {
661
+ $ responseElement = '%$(self).closest("form").attr("data-target")% ' ;
662
+ } else {
663
+ $ responseElement = '%$(self).closest("form").attr("data-target") || " ' . $ responseElement . '"% ' ;
664
+ }
665
+ if (JString::isNull ($ formId )) {
666
+ $ formId = '%$(self).closest("form").attr("id")% ' ;
667
+ } else {
668
+ $ formId = '%$(self).closest("form").attr("id") || " ' . $ formId . '"% ' ;
669
+ }
670
+ if (! isset ($ parameters ['historize ' ])) {
671
+ $ parameters ['historize ' ] = true ;
672
+ }
673
+ return $ this ->postFormOnClick ($ element , '' , $ formId , $ responseElement , $ parameters );
674
+ }
675
+
645
676
private function _post ($ url , $ params = '{} ' , $ responseElement = '' , $ parameters = []) {
646
677
$ parameters ['params ' ] = $ params ;
647
678
return $ this ->_ajax ('POST ' , $ url , $ responseElement , $ parameters );
0 commit comments