Add click listener on on button in Ext.window.MessageBox

10,059

You may use the following construction instead:

Ext.MessageBox.show({
    title: "",
    msg: "message text",
    icon: Ext.MessageBox.WARNING,
    buttons: Ext.MessageBox.OKCANCEL,
    fn: function(buttonId) {
        if (buttonId === "ok") {
            // do on OK pressed
        }
    }
});

Here the first argument in the fn handler is a string value of pressed button.

DEMO: http://jsfiddle.net/xj9qY/

Share:
10,059
Vlad
Author by

Vlad

Application design and development. Software engineering. Bachelor degree in SE (St. Cyril and Methodius, Skopje), Courses for PHP/MySQL, Android 4, Oracle Java SE7 Currently working as senior programmer at State Statistical Office, utilizing, C# / VB.NET / VS2005/ VS2010 / WPF / Access 2000. Reworking old VB6 into new VB.NET apps. Reworking old WinForms apps into WPF with MVVM pattern. Helping others do their job with Access 2000 and SQL. Designing own databases with TSQL. Links GitHub: https://github.com/bluePlayer blog: http://tunephp.blogspot.com

Updated on June 08, 2022

Comments

  • Vlad
    Vlad almost 2 years

    I am creating dinamically a message box (Ext.window.MessageBox)

    var msgBox = Ext.create('Ext.window.MessageBox', {
           title: '',
           //message in window
           msg: 'message text',
           icon: 'WARNING',
           //buttons
           buttons: 'OKCANCEL',
           //onclick funciton
           fn: myfunc
     });
    

    I am adding OK and Cancel buttons. Is it possible to add click listener on the OK button so that I can do my stuff only when this OK button is pressed?

    Also is it possible to add specific ids to the OK and Cancel buttons so that I can distinguish them more easily, instad of using the pregenrated ids from ExtJS?