View Full Version : Problems with MessageBox and <br/>

21 Jul 2011, 3:29 AM
Hi! Iam making my first sencha touch steps and need some help.
I've got a login form getting back an error Message from a Database Function: Sorry, Access denied:<br />Please ensure that you entered the correct User ID - or retry later.
If I give it out as an alert, there's no problem.
If I code it in HTML, there's no problem.
But if I use Ext.Msg.alert(result.error); there' only 'Sorry, Access denied:' in the Message Box and nothing else.
The Database gives back: {"success":false,"error":"Sorry, Access denied:<br/>Please ensure that you entered the correct User ID - or retry later."}

icon: 'icon.png',
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
glossOnIcon: false,
onReady: function() {

var form;

Ext.regModel('User', {
fields: [
{name: 'name', type: 'string'},
{name: 'password', type: 'password'}

var formBase = {
scroll: 'vertical',
url : '/position2/doLogin.php',
standardSubmit : false,
submitOnAction: true,
id: 'POSform',
bodyStyle: 'background: url(/position2/mobile/img/logo_pos2.gif) no-repeat #ffffff;',
items: [{
xtype: 'fieldset',
height: 200,
instructions: 'Please enter the information above.',
id: 'POSFieldset',
bodyStyle: 'margin-top:80px;',
defaults: {
required: true,
labelAlign: 'left',
labelWidth: '40%'
items: [
xtype: 'textfield',
name : 'HASH',
hidden: true,
value: '<?= $hash ?>'
xtype: 'textfield',
name : 'SAVE_LOGIN',
hidden: true,
value: '0'
xtype: 'textfield',
name : 'SAVE_PWD',
hidden: true,
value: '0'
xtype: 'textfield',
name : 'BROWSER_KEY',
hidden: true,
value: '<?= $browser_key ?>'
xtype: 'textfield',
name : 'LOGIN',
label: 'Login',
useClearIcon: true,
autoCapitalize : false
}, {
xtype: 'passwordfield',
name : 'PASSWORD',
label: 'Password',
useClearIcon: false
}, {
xtype: 'button',
text: 'Login',
ui: 'confirm',
handler: function() {
form.updateRecord(formBase.user, true);
waitMsg : {message:'Submitting', cls : 'demos-loading'}
listeners : {
submit : function(form, result){document.location = "/position2/doLogin.php?TRANSID="+result.TRANSID;},
exception : function(form, result){Ext.Msg.alert(result.error);}

if (Ext.is.Phone) {
formBase.fullscreen = true;
} else {
Ext.apply(formBase, {
autoRender: true,
floating: true,
modal: true,
centered: true,
hideOnMaskTap: false,
height: 385,
width: 480

form = new Ext.form.FormPanel(formBase);

Hope this gives you the information you need.

21 Jul 2011, 6:37 AM
Keep in mind that the Ext.Msg.alert() has 3 parameters. It looks like you are putting your 'result.error' as the first parameter which is the title of the alert. I realized this because i had the same problem as you.
My text was getting cut off so maybe it is the same for you.

Try out this code:

Ext.Msg.alert('Error', result.error, Ext.emptyFn );

OR if you wish not to have a title for the alert, just use:

Ext.Msg.alert('', result.error, Ext.emptyFn );

The 3rd parameter is just a callback function.

Hopefully it works out. You may not need the <br /> because the alert wordwraps the text. But you can format it however you like. ;)

Best of luck!

PS: Note that the MessageBox is asynchronous. If you want code to stop you must change the callback function. Refer to the Sencha Touch API under Ext.MessageBox

26 Jul 2011, 9:50 PM
Thanx! It worked ;)