开发者

extJS problem with Button

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);
                        }                                      
                    });
                }
            }
        }, {
        开发者_如何学C    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?


I hope you run the code with URL line in submit not commented, because the submit won't work if you don't specify a URL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜