locked
msls.showMessageBox: Doesn't appear, but alert() works... Why? RRS feed

  • Question

  • Hello,

    We have an LS HTML Client application.  In some locations in our code, when we try to use msls.showMessageBox, it will not appear, but an alert() works properly.  Does anyone know why?  Here is an example...  The first messagebox asking the deletion confirmation works properly, but the second messagebox never appears.  alert() always works, but we'd like to display a title and have all messages presented to the user in the same way.  I'd appreciate your suggestions...

    Thanks,

    Mike

     

        var resp = msls.showMessageBox(msg, {
            title: title,
            buttons: msls.MessageBoxButtons.yesNo
        });

        resp.then(function (val) {
            if (val == msls.MessageBoxResult.yes) {
                screen.Customer.deleteEntity();
                myapp.commitChanges().then(null, function fail(e) {
                    myapp.cancelChanges();

                    var msg = jQuery.validator.format(
                        WinJS.Resources.getString("/client/Error_DeleteFailed").value,
                        screen.Customer.Name,
                        e.message);

                    //var resp = msls.showMessageBox(msg, {
                    //    title: WinJS.Resources.getString("/client/Title_DeleteFailed").value
                    //});
                    alert(msg);

                    throw e;
                });
            }
        });

    Monday, September 16, 2013 9:37 PM

Answers

  • Ok. Yep. Try this.

    myapp.AddEditCustomer.Delete_execute = function (screen) {
        // Write code here.
        var msg = "Are You Sure?";
        var title = "Delete Customer";
    
        var resp = msls.showMessageBox(msg, {
            title: title,
            buttons: msls.MessageBoxButtons.yesNo
        });
    
        resp.then(function (val) {
            if (val == msls.MessageBoxResult.yes) {
                screen.Customer.deleteEntity();
                myapp.commitChanges().then(null, function fail(e) {
                    var errmsg = screen.Customer.Name + e.message;
                    myapp.cancelChanges().then(function () {
    
                        var resp = msls.showMessageBox(errmsg, {
                            title: "ERROR",
                            buttons: msls.MessageBoxButtons.ok
                        });
    
                        throw e;
                    });
    
                });
            }
        });
    };


    Patrick Baker (Visual Studio LightSwitch Test Lead)

    • Marked as answer by A Bit of Help Tuesday, September 17, 2013 6:43 PM
    Tuesday, September 17, 2013 3:54 PM
    Moderator

All replies

  • I only played around with this for a few minutes so pardon the code, but I think you just need to wrap the second msgbox in a promise.

        resp.then(function (val) {
            if (val == msls.MessageBoxResult.yes) {
                screen.Customer.deleteEntity();
                myapp.commitChanges().then(null, function fail(e) {
                    var msg = screen.Customer.Name + e.message;
                    myapp.cancelChanges().then(function (msg, e) {
    
                        var resp = msls.showMessageBox(msg, {
                            title: "/client/Title_DeleteFailed",
                            buttons: msls.MessageBoxButtons.ok
                        });
    
                        throw e;
                    });
    
                });
            }
        });

     

    Patrick Baker (Visual Studio LightSwitch Test Lead)

    Tuesday, September 17, 2013 12:10 AM
    Moderator
  • Hi Patrick,

    Thank you very much for your response and suggestion!  I've implemented the code, but, unfortunately, when I am inside the code-block "myapp.cancelChanges().then(function (msg, e) {", msg and e are undefined.  It is late in the day, so I will take a closer look in the morning and report back...

    Thanks again!

    Mike

    Tuesday, September 17, 2013 1:16 AM
  • Ok. Yep. Try this.

    myapp.AddEditCustomer.Delete_execute = function (screen) {
        // Write code here.
        var msg = "Are You Sure?";
        var title = "Delete Customer";
    
        var resp = msls.showMessageBox(msg, {
            title: title,
            buttons: msls.MessageBoxButtons.yesNo
        });
    
        resp.then(function (val) {
            if (val == msls.MessageBoxResult.yes) {
                screen.Customer.deleteEntity();
                myapp.commitChanges().then(null, function fail(e) {
                    var errmsg = screen.Customer.Name + e.message;
                    myapp.cancelChanges().then(function () {
    
                        var resp = msls.showMessageBox(errmsg, {
                            title: "ERROR",
                            buttons: msls.MessageBoxButtons.ok
                        });
    
                        throw e;
                    });
    
                });
            }
        });
    };


    Patrick Baker (Visual Studio LightSwitch Test Lead)

    • Marked as answer by A Bit of Help Tuesday, September 17, 2013 6:43 PM
    Tuesday, September 17, 2013 3:54 PM
    Moderator
  • You rock, Patrick!  The new code works perfectly!

    Thank you very much for your help! :)

    Mike

    Tuesday, September 17, 2013 6:43 PM