PNotify Default Confirm Buttons - PSA

FYI, I just added some code to Octolapse that will re-add the default confirm buttons to PNotify if they are missing. If your plugin removes the default buttons via the following javascript:

PNotify.prototype.options.confirm.buttons = [];

your plugin will be semi-broken (or at least it will look ugly) by Octolapse. I did this because there are many plugins (most are now patched) that remove all of these buttons, and having an OK and CANCEL button is kind of important for a confirmation dialog :slight_smile: If you need to remove PNotify confirm buttons, use something like the following instead:

            new PNotify({
                title: "My confirm message",
                text: "Some text here",
                type: "error",
                confirm: {
                    confirm: true,
                    buttons: [
                        {
                            text: "No thank you!",
                            click: function(notice) {
                                my_function();
                                notice.remove();
                            }
                        },
                        {
                            text: "Close", // This is the text of the button we want to remove
                            addClass: "remove_button" // Add a class to the button so you can find it later
                        },
                    ]
                },
                before_open: function(notice) {
                    // Remove the button we don't want
                    notice.get().find(".remove_button").remove();
                },
            });

Thanks!

2 Likes