如何在toastr中显示确认对话框 [英] how to show a confirmation dialog box in toastr

查看:228
本文介绍了如何在toastr中显示确认对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在控制器中有一个删除按钮的代码,

I have the below code for a delete button in the controller,

$scope.removes = function (scope) {
        toastr.success("Delete all?","<br /><br /><button type='button' class='btn clear'>Yes</button>",{
            closeButton: false,
            onClick: function(){
                var nodeData = scope.$modelValue;
                            if(nodeData.nodes.length > 0){
                                toastr.error('Cant delete Sub levels available :', 'Warning', {
                                    closeButton: true
                                });
                            }else{
                                mainMenuService.deleteData(nodeData).success(function(data) {
                                    scope.remove();
                                    toastr.success(data.message, 'Message', {
                                        closeButton: true
                                    });
                                }).error(function(err) {
                                    toastr.error(err, 'Warning', {
                                        closeButton: true
                                    });
                                });
                            }
            }
        })
}

我想显示一个确认对话框,如果使用单击是按钮,则要删除。但我在toastr消息中看不到任何按钮,我不知道该怎么做。我完全按照文档中的说法完成了。我想知道是否可以在确认消息中放两个按钮?

I want to show a confirmation dialog box and want to delete if the use click yes button. But I can't see any button in the toastr message and I don't know how to do it. I have done it exactly as in the documentation. And I want to know if it is possible to put two buttons in the confirmation message?

推荐答案

如果有人不是在Angular解决方案之后但又回到了基础,那么它非常简单。

In case anyone is NOT after Angular solution but back to the basics here it is, really simple.

toastr.success("<br /><br /><button type='button' id='confirmationRevertYes' class='btn clear'>Yes</button>",'delete item?',
  {
      closeButton: false,
      allowHtml: true,
      onShown: function (toast) {
          $("#confirmationRevertYes").click(function(){
            console.log('clicked yes');
          });
        }
  });

这篇关于如何在toastr中显示确认对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆