@@ -31,8 +31,10 @@ export default Base.extend({
31
31
} ,
32
32
33
33
registerListeners ( ) {
34
- this . $el . on (
35
- "input-change-delayed.pat-autosubmit" ,
34
+ events . add_event_listener (
35
+ this . el ,
36
+ "input-change-delayed" ,
37
+ "pat-autosubmit--input-change-delayed" ,
36
38
this . onInputChange . bind ( this )
37
39
) ;
38
40
this . registerSubformListeners ( ) ;
@@ -60,15 +62,21 @@ export default Base.extend({
60
62
* that only the subform gets submitted if an element inside it
61
63
* changes.
62
64
*/
63
- const $el = typeof ev !== "undefined" ? $ ( ev . target ) : this . $el ;
64
- $el . find ( ".pat-subform" )
65
- . not ( ".pat-autosubmit" )
66
- . each ( ( idx , el ) => {
67
- $ ( el ) . on (
68
- "input-change-delayed.pat-autosubmit" ,
69
- this . onInputChange . bind ( this )
70
- ) ;
71
- } ) ;
65
+ const el = typeof ev !== "undefined" ? ev . target : this . el ;
66
+
67
+ // get all subforms whice are not yet auto submit forms.
68
+ const subforms = el . querySelectorAll (
69
+ ".pat-autosubmit:not(.pat-autosubmit):not(.pat-auto-submit)"
70
+ ) ;
71
+ for ( const subform of subforms ) {
72
+ // register autosubmit on subform
73
+ events . add_event_listener (
74
+ subform ,
75
+ "input-change-delayed" ,
76
+ "pat-autosubmit--input-change-delayed" ,
77
+ this . onInputChange . bind ( this )
78
+ ) ;
79
+ }
72
80
} ,
73
81
74
82
refreshListeners ( ev , cfg , el , injected ) {
@@ -90,7 +98,7 @@ export default Base.extend({
90
98
if ( $ ( ev . target ) . closest ( ".pat-autosubmit" ) [ 0 ] !== this ) {
91
99
return ;
92
100
}
93
- $ ( ev . target ) . trigger ( "input-change-delayed" ) ;
101
+ ev . target . dispatchEvent ( events . generic_event ( "input-change-delayed" ) ) ;
94
102
}
95
103
if ( this . options . delay === "defocus" ) {
96
104
this . $el . on ( "input-defocus.pat-autosubmit" , trigger_event ) ;
0 commit comments