11import { customElement , bindable , ViewResources , View , processAttributes } from 'aurelia-templating' ;
2+ import { DOM } from 'aurelia-pal' ;
23import { inject } from 'aurelia-dependency-injection' ;
34import { StyleEngine } from '../styles/style-engine' ;
45import { Themable } from '../styles/themable' ;
56import { processDesignAttributes } from '../designs/design-attributes' ;
67
7- @inject ( ViewResources , StyleEngine )
8+ @inject ( Element , ViewResources , StyleEngine )
89@customElement ( 'ux-form' )
910@processAttributes ( processDesignAttributes )
1011
1112export class UxForm implements Themable {
1213 @bindable public theme = null ;
14+ @bindable public submit : any ;
1315
1416 public view : View ;
1517
16- constructor ( public resources : ViewResources , private styleEngine : StyleEngine ) { }
18+ constructor ( private element : Element , public resources : ViewResources , private styleEngine : StyleEngine ) { }
1719
1820 public created ( _ : any , myView : View ) {
1921 this . view = myView ;
@@ -25,12 +27,15 @@ export class UxForm implements Themable {
2527 }
2628 }
2729
28- // public attached() { }
29-
30- // public detached() { }
31-
32-
3330 public themeChanged ( newValue : any ) {
3431 this . styleEngine . applyTheme ( this , newValue ) ;
3532 }
33+
34+ public submitForm ( ) {
35+ if ( this . submit ) {
36+ const submitEvent = DOM . createCustomEvent ( 'submit' , { bubbles : true , target : this . element } ) ;
37+
38+ this . element . dispatchEvent ( submitEvent ) ;
39+ }
40+ }
3641}
0 commit comments