Confirm() misbehavior

I’m trying to fully understand how the confirm() method of the ko/dialogs module works. According to its documentation – at least, the description of the “yes” and “no” properties, but not the description of the method itself – the method should present a dialog box with two buttons, allowing the user to choose either yes or no. But I can’t seem to get two buttons to display. Every combination I have tried so far results in just a single “OK” button. Please see the code below, in which I have commented on the output I’m seeing.

var d = require( "ko/dialogs" );
function dialogs_module_confirm__test(
    ) {
    //  Only displayed is a OK button, but no Cancel button.
    var return_value = d.alert( "confirm() message" );

    //  The method always returns false even though the user is choosing the OK button.
    assert( ! return_value );

    //  The button label is not given the value specified here.
    d.alert( "confirm() override labels", { yes: "Okey-dokey", no: "No way, Jose" } );

The three questions I have are:

  1. How I can get the two buttons to be shown instead of just one?
  2. How can I change the labels of the buttons?
  3. Why does the method always returns false even though the user is clicking the OK button (which is generally considered an affirmative response and not negative)?

You’re calling .alert(), not .confirm().

Here’s a working example:

require("ko/dialogs").confirm("foo", {yes: "yes", no: "no"})

Oh, good gracious. Pardon me while I put on a dunce cap and go sit in the corner for a while. :slight_smile: Unbelievable. And I now realize how this happened: Prior I had created a test function for alert(), and then copied and pasted it. But I skipped the critical third step – edit all the code.

Thanks for the reply. :slight_smile:

Happens to us all :slight_smile: