]> git.proxmox.com Git - extjs.git/blob - extjs/examples/kitchensink/classic/samples/view/form/ContactFormController.js
add extjs 6.0.1 sources
[extjs.git] / extjs / examples / kitchensink / classic / samples / view / form / ContactFormController.js
1 Ext.define('KitchenSink.view.form.ContactFormController', {
2 extend: 'Ext.app.ViewController',
3 alias: 'controller.form-contact',
4
5 showWindow: function() {
6 var win = this.lookupReference('popupWindow');
7
8 if (!win) {
9 win = new KitchenSink.view.form.ContactFormWindow();
10
11 // A Window is a floating component, so by default it is not connected
12 // to our main View in any way. By adding it, we are creating this link
13 // and allow the window to be controlled by the main ViewController,
14 // as well as be destroyed automatically along with the main View.
15 this.getView().add(win);
16 }
17
18 win.show();
19 },
20
21 onFormCancel: function() {
22 this.lookupReference('windowForm').getForm().reset();
23 this.lookupReference('popupWindow').hide();
24 },
25
26 onFormSubmit: function() {
27 var formPanel = this.lookupReference('windowForm'),
28 form = formPanel.getForm();
29
30 if (form.isValid()) {
31 // In a real application, this would submit the form to the configured url
32 // form.submit();
33 form.reset();
34 this.lookupReference('popupWindow').hide();
35 Ext.MessageBox.alert(
36 'Thank you!',
37 'Your inquiry has been sent. We will respond as soon as possible.'
38 );
39 }
40 }
41 });