Как использовать JConfirm с условными обозначениями?

Можно ли использовать плагин JConfirm с инструкциями if для отображения разных кнопок во всплывающем окне, или его нужно просто жестко закодировать?

Я планировал в своей голове что-то вроде следующего:

если аккаунт активирован

-> да, отобразить кнопку деактивации

-> нет, отобразить кнопку активации

Который будет кодировать что-то вроде следующего:

                $.confirm({
                    icon: 'fas fa-users',
                    title: 'User Account: $name',
                    content: 'What would you like to do with this account?',
                    buttons: {
                        View: {
                            btnClass: 'btn-info',
                            text: 'View Profile',
                            action: function () {
                                // Take them to a link
                            }
                        },
                        Upgrade: {
                            btnClass: 'btn-info',
                            text: 'Upgrade to Tutor',
                            action: function () {
                                $.alert('Account successfully upgraded!');
                            }
                        },
                        Ban: {
                            btnClass: 'btn-danger',
                            text: 'Ban Account',
                            action: function () {
                                $.alert('Account has now been banned :(');
                            }
                        },
                        if(activated === '1'){
                        Deactivate: {
                            btnClass: 'btn-warning',
                            text: 'Deactivate Account',
                            action: function () {
                                $.alert('Account has now deactivted :(');
                            }
                        }
                        } else {
                        Deactivate: {
                            btnClass: 'btn-warning',
                            text: 'Activate Account',
                            action: function () {
                                $.alert('Account has now deactivted :(');
                            }
                        }
                        }
                        Reset: {
                            btnClass: 'btn-success',
                            text: 'Reset Password',
                            action: function () {
                                $.alert('User has been e-mailed a forgotten password link');
                            }
                        },
                        Close: {
                            btnClass: 'btn-default',
                            text: 'Close'
                        }   
                    }
                });

Этот код не работает в настоящее время, что было бы возможным для этого?

0 ответов

Другие вопросы по тегам