Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extjs 4 MessageBox prompt mandatory

Tags:

extjs

extjs4

Is there any way to make the input mandatory on a prompt messagebox in extjs 4, like add an allowBlank config to the textarea...

like image 615
nscrob Avatar asked Dec 29 '25 02:12

nscrob


1 Answers

Ext.MessageBox unfortunately does not support controlling the close-behavior based on the return value of the login handler (at least in Ext 4.0.2a the return value is not evaluated at all).

As a workaround you can just re-open another MessageBox in your callback handler with the same (or updated) config.

Ext.Msg.prompt('Name', 'Please enter your name:', function(btn, text, cfg) {
    if(btn == 'ok' && Ext.isEmpty(text)) {
        var newMsg = '<span style="color:red">Please enter your name:</span>';
        Ext.Msg.show(Ext.apply({}, { msg: newMsg }, cfg));
    }
});

In some cases the user could experience a slight flickering. In my tests, however, it was not noticeable at all. If the user has dragged the MessageBox to a different position it will recenter again.

like image 131
mistaecko Avatar answered Dec 30 '25 23:12

mistaecko