Hey guys! I was hoping I could get some feed back on the structure of my code below.
I wanted to know from a structure standpoint what is good and bad. Should move some things around or is it good the way that it is?
I also stripped out the code specific to this app and keep it general so theoretically it could be used in any app.
This is such a common, but important feature so I wanted to make sure I wasn't missing some important thing.
If anyone wants to tear it apart and let me know what I could do to write better code that would be amazing.
Thanks!
PHP Code:
Ext.define('MyApp.controller.UserAccount', {
extend: 'Ext.app.Controller',
config: {
control: {
'login #loginBtn': {
tap : 'login'
},
'login #registerBtn': {
tap : 'register'
},
'login #forgotBtn': {
tap : 'forgot'
}
}
},
init: {...},
launch: {...},
login: function (me) {
var form = me.up('form');
var values = form.getValues();
var route = '/login';
Ext.Viewport.Mask();
this.submitToServer(values, route);
},
register: function (me) {
var form = me.up('form');
var values = form.getValues();
var route = '/register';
Ext.Viewport.Mask();
this.submitToServer(values, route);
},
forgot: function (me) {
var form = me.up('form');
var values = form.getValues();
var route = '/forgot';
Ext.Viewport.Mask();
this.submitToServer(values, route);
},
submitToServer: function (values, route) {
var onSuccess = function (response) {...};
var onFailure = function (response) {...};
var onCallback = function () {...};
Ext.data.JsonP.request({
url: app_global.server + route,
timeout: 10000,
callbackKey: 'callback',
params: values,
scope: this,
success: onSuccess,
failure: onFailure,
callback: onCallback
});
}
});