Results 1 to 4 of 4

Thread: Ext.MessageBox.prompt to password

  1. #1
    Sencha User
    Join Date
    Jun 2011
    Location
    Russia
    Posts
    39
    Vote Rating
    1
      0  

    Default Answered: Ext.MessageBox.prompt to password

    Hi,

    I try to change default textField (input) in Ext.MessageBox.prompt dialog, but can't do this. This field should be launch when user click the button and try to upload file.

    Search result give me this:
    http://www.sencha.com/forum/showthre...ssword-control
    but it doesn't works.

    Does any one knows how to do that?

    Code:
    Ext.MessageBox.prompt('login', 'input password:', function(btn, text){ 
        if (btn === 'ok'){
            var form = Ext.getCmp('formPanelManager').getForm();
            if(form.isValid()){
                form.submit({
                    
                    url: 'controller/tab_manage/uploadConfig.php',
                    params: { upas: text },
                    success: function(fp, o) {
                        
                        console.info(o);
                        if ( o.result.success == "true") {
                            // success
                        } else if(o.result.success != true) {
                            // error
                        }
                    }
                });
                Ext.getCmp('panelUpdate').items.items[0].value = '';
            }
        }
    });

    Thanks.

    1. You are referencing a thread from Ext JS 2 so I wouldn't expect it to work.
    2. Ext.window.MessageBox isn't very customizable. Simply, it already creates a textfield and you can't configure that textfield.


    So it's not easy so since Ext.window.MessageBox extends Ext.window.Window and just adds components, you could just create your own Ext.window.Window

  2. #2
    Sencha User
    Join Date
    Nov 2011
    Posts
    39
    Answers
    5
    Vote Rating
    0
      0  

    Default

    You can't. Take a look at the prompt method:
    Code:
        prompt : function(cfg, msg, fn, scope, multiline, value){
            if (Ext.isString(cfg)) {
                cfg = {
                    prompt: true,
                    title: cfg,
                    minWidth: this.minPromptWidth,
                    msg: msg,
                    buttons: this.OKCANCEL,
                    callback: fn,
                    scope: scope,
                    multiline: multiline,
                    value: value
                };
            }
            return this.show(cfg);
        }
    Enjoy my solution:
    Code:
        var w = Ext.MessageBox.show({
          prompt: true,
          title: 'Prompt',
          msg: 'msg',
          buttons: Ext.MessageBox.OKCANCEL
        });
        w.getEl().dom.children[1].children[0].children[1].children[1].children[0].children[0].setAttribute('type', 'password');
    ^^

  3. #3
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,554
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    1. You are referencing a thread from Ext JS 2 so I wouldn't expect it to work.
    2. Ext.window.MessageBox isn't very customizable. Simply, it already creates a textfield and you can't configure that textfield.


    So it's not easy so since Ext.window.MessageBox extends Ext.window.Window and just adds components, you could just create your own Ext.window.Window
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  4. #4
    Sencha User
    Join Date
    Jun 2011
    Location
    Russia
    Posts
    39
    Vote Rating
    1
      0  

    Default

    As mitchellsimoens said,

    So it's not easy so since Ext.window.MessageBox extends Ext.window.Window and just adds components, you could just create your own Ext.window.Window
    I created my own Window with components and submit upload form by button click.

    Code:
    xtype: 'button',
    id: 'confirmButton',
    width: 75,
    text: 'Ok',
    margins: '0 10 0 0',
    formBind: true,
    handler: function(){
        var form  = this.up('form').getForm();
        var ftext = form.getValues().upass;
        var manageForm = Ext.getCmp('formPanelManager').getForm();
        if(manageForm.isValid()){
            
            manageForm.submit({
                url: 'controller/tab_manage/uploadConfig.php',
                params: { upass: ftext },
                success: function(fp, o) {
                    console.info(o);
                    if ( o.result.success == "true") {
                        // MSG SUCCESS
                    } else if(o.result.success != true) {
                        // MSG ERROR
                    }                                                       
                },
                failure: function(form, action){
                    console.info("ERROR ", action); //...
                    Ext.MessageBox.show({title: 'Error.', msg: 'Error# <br />' + action.result.msg, buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.ERROR});
                }  
            });
            Ext.getCmp('panelUpdate').items.items[0].value = '';
            Ext.getCmp('confirmWindow').close(); 
        }
    }
    P.S. Araberen, first of all, I thought the save way to get input component by call child[0] ...child[1] ...child... But this is dirty hack

    Thanks for yours advices!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •