Results 1 to 7 of 7

Thread: Basic MessageBox.show does not call its callback function

  1. #1
    Sencha User rbraddy's Avatar
    Join Date
    Jul 2009
    Location
    Houston, TX
    Posts
    144
    Answers
    1
    Vote Rating
    8
      0  

    Default Basic MessageBox.show does not call its callback function

    Hi,

    I have copied the following code from a working project into a new project, and it does not call the async callback "fn" for some reason. This code is called within a Delete button handler callback:

    Code:
            var msgStr;
            msgStr = "Are you sure you want to delete '" + theTarget + "' ?";
            Ext.MessageBox.show({
                title:'Delete Confirm',
                msg: msgStr,
                buttons: Ext.MessageBox.YESNOCANCEL,
                fn:  confirmDelete,
                icon: Ext.MessageBox.WARNING
            });
    The message box displays correctly. When the "Yes" button is pressed, nothing happens (in debugger in Chrome or Firebug, the callback event confirmDelete() is not triggered). No console errors. I also tried an inline config function "fn: function(btn, text, options) { ... }" and it does not get called, either.

    Thoughts on how to resolve/troubleshoot? Clearly, the MessageBox is not calling my callback for some reason... (do I need to drop down into ExtJS debug land to resolve??)

    Weird thing is, nearly this exact code is working in all my other projects.

    Thanks
    Rick
    Last edited by rbraddy; 6 Mar 2013 at 2:17 PM. Reason: added code tags

  2. #2
    Sencha User
    Join Date
    Jan 2009
    Location
    Ottawa, ON, Canada
    Posts
    81
    Answers
    6
    Vote Rating
    1
      0  

    Default

    I'm almost afraid to answer this because I'm really not that confident an ExtJs user myself but, just in case it helps, the first thing I'd look in to is whether the "confirmDelete" function is actually in scope when you make the Ext.MessageBox.show call.

    Sorry if this doesn't help and just confuses the issue but so many people help me in this forum, I thought that since I actually had an idea, I should post it.

    Good luck!
    jtm

  3. #3
    Sencha User rbraddy's Avatar
    Join Date
    Jul 2009
    Location
    Houston, TX
    Posts
    144
    Answers
    1
    Vote Rating
    8
      0  

    Default

    Thanks for the response. That could be it, except there's no error message in the console window (the function's not being called), and originally there was just a configured "fn: function()..." statement inline, and it does not get called either.

  4. #4
    Sencha User
    Join Date
    Jan 2009
    Location
    Ottawa, ON, Canada
    Posts
    81
    Answers
    6
    Vote Rating
    1
      0  

    Default

    Can you put a debugger; statement just before your "Ext.MessageBox.show" line and see if confirmDelete has a value at that time or if it's just null?

  5. #5
    Sencha User rbraddy's Avatar
    Join Date
    Jul 2009
    Location
    Houston, TX
    Posts
    144
    Answers
    1
    Vote Rating
    8
      0  

    Default

    Yes. It is a valid function of the controller:

    MessageBoxDebug1.jpg
    Attached Images Attached Images

  6. #6
    Ext JS Premium Member devtig's Avatar
    Join Date
    Jan 2010
    Location
    Rotterdam, The Netherlands
    Posts
    422
    Vote Rating
    15
      0  

    Default

    Exact same thing here. Weird. Rewriting to
    Code:
    Ext.MessageBox.confirm(title, message, function(buttonId) {console.log(arguments)});
    didn't help to get the callback called either.

    @rbraddy (How) did you get it solved?

    I'm sure it's due to some other button event handler sitting in the way. Maybe that interrupts the event and prevents it from reaching this single event handler...

    ...debugging other event handlers now, will update here later...

    Yes, what I assumed was indeed the case. Another generic button event handler that I created, did not handle 'yes' and showed another MessageBox telling that the user that the button is not functional yet. That cancelled the event for the original MessageBox. I removed the second MessageBox and the callback worked.
    Christiaan Westerbeek @ Devotis
    Contact me for help with Ext JS, Node JS, FireBase, AngularJS and Javascript in general. Email me or find me at AirPair to connect.

  7. #7
    Sencha User rawsonkara's Avatar
    Join Date
    Dec 2009
    Location
    CT
    Posts
    10
    Answers
    1
    Vote Rating
    1
      0  

    Default

    You need to declare your scope, if you don't it will use your messagebox's scope instead. here is an example one of our messagebox classes.

    Code:
    Ext.define('ContentSchedule.components.SaveConfirmMessageBox', {
        extend: 'Ext.window.MessageBox',
        modal: true,
        width: 600,
        height: 150,
        id: 'saveConfirmMessageBox',
        cls: 'cs_messageBox_saveConfirm',
        xtype: 'saveConfirmMessageBox',
        layout: {
            type: 'vbox',
            align: 'stretch'
        },
        initComponent: function () {
            this.callParent(arguments);
        },
        showMask: function (scope, callback) {
            this.show({
                title: ContentSchedule.lang.StringBundle.pendingChangeMessage,
                buttons: Ext.Msg.YESNOCANCEL,
                icon: Ext.Msg.QUESTION,
                scope: scope,
                fn: callback,
                msg: ContentSchedule.lang.StringBundle.pendingChangeMessageBody
            });
        }
    });
    the showMask function is a helper function that calls the base .show() function. This is done so that we can explicitly inject the scope and callback function based on the various view components which might trigger this confirmation to be shown.

Posting Permissions

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