Created
June 28, 2017 15:23
-
-
Save mschwartz/09ecae0bb955d13539b06062448a5185 to your computer and use it in GitHub Desktop.
Test for deferred: false
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The main application class. An instance of this class is created by app.js when it | |
* calls Ext.application(). This is the ideal place to handle application launch and | |
* initialization details. | |
*/ | |
Ext.define('test.Application', { | |
extend: 'Ext.app.Application', | |
name: 'test', | |
requires: [ | |
'Ext.MessageBox', | |
'Ext.app.ViewModel' | |
], | |
stores: [ | |
// TODO: add global / shared stores here | |
], | |
launch: function () { | |
Ext.Viewport.add({ | |
xtype: 'formpanel', | |
title: 'test', | |
viewModel: { | |
data: { | |
field1: 'abc', | |
field2: 'def', | |
field3: 'ghi' | |
} | |
}, | |
layout: { | |
type: 'card', | |
deferRender: false | |
}, | |
items: [ | |
{ | |
xtype: 'toolbar', | |
docked: 'bottom', | |
items: [ | |
{ | |
xtype: 'button', | |
text: 'submit', | |
handler: function() { | |
var panel = this.up('formpanel'), | |
fields = panel.getFields(), | |
errors = 'All fields are valid', | |
valid; | |
panel.validate(); | |
valid = panel.isValid(); | |
if (!valid) { | |
errors = Object.keys(fields).map(function(key) { | |
var field = fields[key]; | |
if (!field.isValid()) { | |
return '<li>' + field.name + ': "' + field.getValue() + '"</li>'; | |
} | |
}); | |
errors = '<h2>Invalid fields:</h2><ul>' + errors.join('') + '</ul>'; | |
} | |
Ext.Msg.alert(valid ? 'VALID' : 'INVALID', errors); | |
} | |
}, | |
'->', | |
{ | |
xtype: 'button', | |
text: 'prev', | |
handler: function() { | |
this.up('formpanel').getLayout().previous(); | |
} | |
}, | |
{ | |
xtype: 'button', | |
text: 'next', | |
handler: function() { | |
this.up('formpanel').getLayout().next(); | |
} | |
} | |
] | |
}, | |
{ | |
padding: 10, | |
items: [ | |
{ | |
xtype: 'textfield', | |
label: 'card1', | |
name: 'card1', | |
required: true, | |
bind: '{field1}' | |
} | |
] | |
}, | |
{ | |
padding: 10, | |
items: [ | |
{ | |
xtype: 'textfield', | |
label: 'card2', | |
name: 'card2', | |
required: true, | |
bind: '{field2}' | |
} | |
] | |
}, | |
{ | |
padding: 10, | |
items: [ | |
{ | |
xtype: 'textfield', | |
label: 'card3', | |
name: 'card3', | |
required: true, | |
bind: '{field3}' | |
} | |
] | |
}, | |
] | |
}) | |
}, | |
onAppUpdate: function () { | |
Ext.Msg.confirm('Application Update', 'This application has an update, reload?', | |
function (choice) { | |
if (choice === 'yes') { | |
window.location.reload(); | |
} | |
} | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment