PDA

View Full Version : Problem with Button!



vitalka
23 May 2011, 6:45 AM
I have following code:

Ext.BLANK_IMAGE_URL = './ext/resources/images/default/s.gif';

Ext.onReady(function(){

Ext.QuickTips.init();

var addQuestionForm = new Ext.form.FormPanel({
frame :true,
method : 'POST',
items: [
{
xtype :'htmleditor',
width : "99%",
height : 200,
fieldLabel :'Question',
name :'question[text]',

}
],


buttonAlign: 'center',
buttons: [{
text : 'Submit',
height : 30,
icon : '/images/icons/silk/accept.png',
scale : 'large',
width : 500,
handler : function(){
if(addQuestionForm.getForm().isValid()){
addQuestionForm.getForm().submit({
// url:'/answers/create',
// waitMsg: 'Please wait...',
success : function(form, action) {
Ext.MessageBox.alert('Success!', 'Good job!');
// surveyWindow.close();
var redirect = '/admin/private_zone';
window.location = redirect;
},
failure: function(form, action){
Ext.MessageBox.alert('Failure!', action.result.msg);
}
});
}
}
},
{
text:'Cancel',
handler: function(){
var redirect = '/admin/private_zone';
window.location = redirect;
}
}]

});

var addQuestionWindow = new Ext.Window({
title : 'Add Question',
layout : 'form',
id : 'id-form',
width : 800,
height : 800,
modal : true,
closable : false,
resizable : false,
draggable : false,
autowidth : true,
closeAction : 'hide',
bodyStyle : 'padding: 10px',
items : [addQuestionForm]

});

addQuestionWindow.show();

}); Problem is: When i press "ADD" button, firstly nothing happens and secondly I retur on my login page where i should write login & password. WTF? SO i think session is destroyed when i press button ? How to avoid this? Don;t understand. Maybe something wrong with my code in button?

jay@moduscreate.com
24 May 2011, 4:00 PM
Ext.MessageBox.alert is non blocking, so your window.location will fire!