Sencha Touch 2 – Comment obtenir des valeurs de formulaire?

J'ai une application MVC Sencha Touch 2 avec une forme comme vue. J'essaie d'obtenir des valeurs du contrôleur sans succès.

Comment cela pourrait-il être fait? Je publie mon code de vue / contrôleur pour celui-ci.

Vue:

Ext.define('MyApp.view.LoginForm', { extend: 'Ext.form.Panel', config: { fullscreen: true, items: [ { xtype: 'fieldset', title: 'Login', id: 'loginform', items: [ { xtype: 'emailfield', name: 'email', label: 'Email' }, { xtype: 'passwordfield', name: 'password', label: 'Password' } ] }, { xtype: 'button', width: '50%', text: 'Login', ui: 'confirm', id: 'btnSubmitLogin' }, { xtype: 'toolbar', docked: 'top', title: 'MyApp Mobile' } ] } }); 

Et le contrôleur:

 Ext.define("MyApp.controller.LoginForm", { extend: "Ext.app.Controller", config: { refs: { btnSubmitLogin: "#btnSubmitLogin" }, control: { btnSubmitLogin: { tap: "onSubmitLogin" } } }, onSubmitLogin: function () { console.log("onSubmitLogin"); var values = app.views.LoginForm.loginform.getValues(); TryLogin(values['email'], values['password']); }, launch: function () { this.callParent(); console.log("LoginForm launch"); }, init: function () { this.callParent(); console.log("LoginForm init"); } }); 

Le code va jusqu'à

 console.log("onSubmitLogin"); 

Et puis arrêtez-vous.

Au lancement j'utilise ceci:

 var LoginForm = Ext.create("MyApp.view.LoginForm"); Ext.Viewport.add(LoginForm); 

Alors, comment puis-je obtenir les valeurs?

Merci

D'accord. Trouvé la réponse après quelques ajustements. Pour l'avenir des générations futures – voici la solution:

J'ai ajouté id:'loginform' au formulaire de connexion, puis, dans le contrôleur dans la partie loginForm: '#loginform' j'ai ajouté loginForm: '#loginform' . Ensuite, je pourrais l'utiliser comme suit:

 var values = this.getLoginForm().getValues(); 

Bonne chance à tous

Essaye ça

Manette:


     Ext.define ("mySIMS.controller.LoginForm", {
         Étendre: "Ext.app.Controller",
         Config: {
             Refs: {
                 BtnSubmitLogin: "#btnSubmitLogin",
                 LoginForm: '#loginform'
             },
             Contrôle: {
                 BtnSubmitLogin: {
                     Appuyez sur: "onSubmitLogin"
                 }
             }
         },
         OnSubmitLogin: function () {
             Console.log ("onSubmitLogin");
             Var values ​​= this.getLoginForm (). GetValues ​​();
             Console.log (valeurs);

             // var values ​​= Oreilly.views.LoginForm.loginform.getValues ​​();

         },
         Lancement: function () {
             This.callParent ();
             Console.log ("LoginForm lancer");
         },
         Init: function () {
             This.callParent ();
             Console.log ("LoginForm init");
         }
     });

Vue:


     Ext.define ('mySIMS.view.LoginForm', {
         Étendre: 'Ext.form.Panel',
         Config: {
             Id: 'loginform',
             Plein écran: vrai
             articles : [{
                 Xtype: 'fieldset',
                 Titre: 'Login',
                 articles : [{
                     Xtype: 'emailfield',
                     Nom: 'email',
                     Label: 'Email'
                 }, {
                     Xtype: 'passwordfield',
                     Nom: 'mot de passe',
                     Label: 'Mot de passe'
                 }]
             }, {
                 Xtype: 'button',
                 Largeur: '8%',
                 Texte: 'Login',
                 Ui: 'confirmer',
                 Id: 'btnSubmitLogin'
             }, {
                 Xtype: 'toolbar',
                 Amarré: «haut»,
                 Titre: 'Mobile'
             }]
         }
     });

J'espère que cette aide.