@@ -602,7 +602,7 @@ public function getOnClick($element, $url, $responseElement = '', $parameters =
602602 * @param string $responseElement
603603 * the target of the ajax request (data-target attribute of the element is used if responseElement is omited)
604604 * @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 )
606606 * @return $this
607607 */
608608 public function getHref ($ element , $ responseElement = "" , $ parameters = array ()) {
@@ -626,7 +626,7 @@ public function getHref($element, $responseElement = "", $parameters = array())
626626 * @param string $responseElement
627627 * the target of the ajax request (data-target attribute of the element is used if responseElement is omited)
628628 * @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 )
630630 * @return $this
631631 */
632632 public function postHref ($ element , $ responseElement = "" , $ parameters = array ()) {
@@ -642,6 +642,37 @@ public function postHref($element, $responseElement = "", $parameters = array())
642642 return $ this ->postOnClick ($ element , '' , '{} ' , $ responseElement , $ parameters );
643643 }
644644
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+
645676 private function _post ($ url , $ params = '{} ' , $ responseElement = '' , $ parameters = []) {
646677 $ parameters ['params ' ] = $ params ;
647678 return $ this ->_ajax ('POST ' , $ url , $ responseElement , $ parameters );
0 commit comments