@@ -31,8 +31,10 @@ export default Base.extend({
3131 } ,
3232
3333 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" ,
3638 this . onInputChange . bind ( this )
3739 ) ;
3840 this . registerSubformListeners ( ) ;
@@ -60,15 +62,21 @@ export default Base.extend({
6062 * that only the subform gets submitted if an element inside it
6163 * changes.
6264 */
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+ }
7280 } ,
7381
7482 refreshListeners ( ev , cfg , el , injected ) {
@@ -90,7 +98,7 @@ export default Base.extend({
9098 if ( $ ( ev . target ) . closest ( ".pat-autosubmit" ) [ 0 ] !== this ) {
9199 return ;
92100 }
93- $ ( ev . target ) . trigger ( "input-change-delayed" ) ;
101+ ev . target . dispatchEvent ( events . generic_event ( "input-change-delayed" ) ) ;
94102 }
95103 if ( this . options . delay === "defocus" ) {
96104 this . $el . on ( "input-defocus.pat-autosubmit" , trigger_event ) ;
0 commit comments