@@ -193,7 +193,10 @@ const inject = {
193193        const  $button  =  $ ( e . target ) ; 
194194        const  formaction  =  $button . attr ( "formaction" ) ; 
195195        const  $form  =  $button . parents ( ".pat-inject" ) . first ( ) ; 
196-         const  opts  =  {  url : formaction  } ; 
196+         const  opts  =  { 
197+             url : formaction , 
198+             $formaction_button : $button , 
199+         } ; 
197200        const  $cfg_node  =  $button . closest ( "[data-pat-inject]" ) ; 
198201        const  cfgs  =  this . extractConfig ( $cfg_node ,  opts ) ; 
199202
@@ -239,6 +242,15 @@ const inject = {
239242                $el . parents ( "form" ) . attr ( "action" )  || 
240243                "" ; 
241244
245+             if  ( 
246+                 opts . $formaction_button  && 
247+                 ( cfg . target  ||  "" ) . startsWith ( "self" ) 
248+             )  { 
249+                 // In case of button formaction submit with target ``self``, 
250+                 // set it. Otherwise the ``form`` will be used as target. 
251+                 cfg . $target  =  opts . $formaction_button ; 
252+             } 
253+ 
242254            // separate selector from url 
243255            const  urlparts  =  cfg . url . split ( "#" ) ; 
244256            cfg . url  =  urlparts [ 0 ] ; 
@@ -311,9 +323,10 @@ const inject = {
311323         * cfg.$target. 
312324         */ 
313325        // make sure target exist 
314-         if  ( cfg . target  ===  "none" ) 
326+         if  ( cfg . target  ===  "none" )   { 
315327            // special case, we don't want to inject anything 
316328            return  true ; 
329+         } 
317330        cfg . $target  = 
318331            cfg . $target  ||  ( cfg . target  ===  "self"  ? $el  : $ ( cfg . target ) ) ; 
319332        if  ( cfg . $target . length  ===  0 )  { 
0 commit comments