我的控制器
Ext.define('MyApp.controller.login', {
extend: 'Ext.app.Controller',
requires: ['MyApp.view.login', 'Ext.field.Input', 'Ext.Ajax'],
config: {
refs: {
loginButton : ' login #logInButton',
loginform : 'login #loginform'
},
control: {
loginButton:{
tap: 'loginButton'
}
}
},
//functions
loginButton: function(){
Ext.Msg.alert('Logged In');
Ext.Ajax.request({
url: getLogonUrl(),
method: 'POST',
params: {
username: Ext.getCmp('username').getValue(),
password: Ext.getCmp('password').getValue(),
},
success: function (response) {
Ext.Msg.alert('Logged In');
var result = Ext.JSON.decode(response.responseText);
console.log(resultResponse.Texts);
if (result.success === "true")
Ext.Msg.alert('Logged In');
else
Ext.Msg.alert('Not Logged In');
},
});
}
});
我在视野中登录
Ext.define('MyApp.view.login', {
extend: 'Ext.form.Panel',
alias: "widget.loginview",
xtype: 'login',
requires: [
'Ext.form.FieldSet','Ext.field.Text', 'Ext.Button',
'Ext.field.Password','Ext.field.Hidden', 'Ext.Img'
],
config:{
id: 'loginform',
iconCls: 'user',
title: 'Login',
styleHtmlCls: true,
styleHtmlContent: true,
scrollable: null,
items: [
{
xtype: 'image',
src:'app/view/img/airitlogo.png',
height: 200,
style:{ top: '100px'},
},
{
xtype: 'fieldset',
width: 1500,
height: 200,
style: ' margin: 150px 0px 0px 200px', // backgroundColor: ' #015486'}
cls: 'login',
title: '<div id="title">PROPworks - Meter Sign In</div>',
items: [
{
xtype: 'label',
html: 'Activation failed',
itemId: 'failLogin',
hidden: true,
hideAnimation: 'fadeOut',
showAnimation: 'fadeIn',
style: 'background: yellow; margin: 5px, 0px',
},
{
xtype: 'textfield',
placeHolder: 'Username',
Id: 'username',
name : 'usernameTextField',
style: 'height: 60px',
},
{
xtype: 'passwordfield',
placeHolder: 'Password',
Id: 'password',
name : 'passwordTextField',
style: 'height: 60px',
}
]//second item list
},
{
xtype: 'button',
itemId: 'logInButton',
text: 'Log In',
ui: 'confirm',
cls: 'button',
width: 1500,
style: ' margin: 15px 0px 0px 200px; height: 70px',
},
]//first item list
}
});
一个Ext.msg.alert()
,一旦超过 ajax.request 就行不通,我的url是一个从我在html文件头部导入的文件中调用的函数
<!DOCTYPE HTML>
<html manifest="" lang="en-US">
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="js/pwmain-ui.js"></script>
<script type="text/javascript" src="js/jquery.min.js"> </script>
<script type="text/javascript" src="js/jquery-ui.js"> </script>
<script type="text/javascript" src="js/jsonselect.min.js"> </script>
<script type="text/javascript" src="js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="js/jquery.atmosphere.js"> </script>
<title>MyApp</title>
答案 0 :(得分:2)
您的代码中有许多不必要的,
可能会破坏sencha。
也许我错了,但你不应该在关闭,
或}
括号之前放]
。
我试图清理这些。这些可以很容易地打破sencha。至少我对这些事情有很多问题。
Ext.define('MyApp.controller.login', {
extend: 'Ext.app.Controller',
requires: ['MyApp.view.login', 'Ext.field.Input', 'Ext.Ajax'],
config: {
refs: {
loginButton : ' login #logInButton',
loginform : 'login #loginform'
},
control: {
loginButton:{
tap: 'loginButton'
}
}
},
//functions
loginButton: function(){
Ext.Msg.alert('Logged In');
Ext.Ajax.request({
url: getLogonUrl(),
method: 'POST',
params: {
username: Ext.getCmp('username').getValue(),
password: Ext.getCmp('password').getValue()
},
success: function (response) {
Ext.Msg.alert('Logged In');
var result = Ext.JSON.decode(response.responseText);
console.log(resultResponse.Texts);
if (result.success === "true")
Ext.Msg.alert('Logged In');
else
Ext.Msg.alert('Not Logged In');
}
});
}
});
在视图中登录:
Ext.define('MyApp.view.login', {
extend: 'Ext.form.Panel',
alias: "widget.loginview",
xtype: 'login',
requires: [
'Ext.form.FieldSet','Ext.field.Text', 'Ext.Button',
'Ext.field.Password','Ext.field.Hidden', 'Ext.Img'
],
config:{
id: 'loginform',
iconCls: 'user',
title: 'Login',
styleHtmlCls: true,
styleHtmlContent: true,
scrollable: null,
items: [
{
xtype: 'image',
src:'app/view/img/airitlogo.png',
height: 200,
style:{ top: '100px'}
},
{
xtype: 'fieldset',
width: 1500,
height: 200,
style: ' margin: 150px 0px 0px 200px', // backgroundColor: ' #015486'}
cls: 'login',
title: '<div id="title">PROPworks - Meter Sign In</div>',
items: [
{
xtype: 'label',
html: 'Activation failed',
itemId: 'failLogin',
hidden: true,
hideAnimation: 'fadeOut',
showAnimation: 'fadeIn',
style: 'background: yellow; margin: 5px, 0px'
},
{
xtype: 'textfield',
placeHolder: 'Username',
Id: 'username',
name : 'usernameTextField',
style: 'height: 60px'
},
{
xtype: 'passwordfield',
placeHolder: 'Password',
Id: 'password',
name : 'passwordTextField',
style: 'height: 60px'
}
]//second item list
},
{
xtype: 'button',
itemId: 'logInButton',
text: 'Log In',
ui: 'confirm',
cls: 'button',
width: 1500,
style: 'margin: 15px 0px 0px 200px; height: 70px'
}
]//first item list
}
});