-import {onEnterPress, onSelect} from "../services/dom";
+import {onEnterPress, onSelect} from '../services/dom.ts';
+import {Component} from './component';
/**
* Ajax Form
*
* Will handle a real form if that's what the component is added to
* otherwise will act as a fake form element.
- *
- * @extends {Component}
*/
-class AjaxForm {
+export class AjaxForm extends Component {
+
setup() {
this.container = this.$el;
this.responseContainer = this.container;
}
setupListeners() {
-
if (this.container.tagName === 'FORM') {
this.container.addEventListener('submit', this.submitRealForm.bind(this));
return;
submitFakeForm() {
const fd = new FormData();
- const inputs = this.container.querySelectorAll(`[name]`);
+ const inputs = this.container.querySelectorAll('[name]');
for (const input of inputs) {
fd.append(input.getAttribute('name'), input.value);
}
this.responseContainer.innerHTML = err.data;
}
- window.components.init(this.responseContainer);
+ window.$components.init(this.responseContainer);
this.responseContainer.style.opacity = null;
this.responseContainer.style.pointerEvents = null;
}
}
-
-export default AjaxForm;
\ No newline at end of file