javascript Toastr js 添加同意/不同意按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24428529/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 02:46:44  来源:igfitidea点击:

Toastr js add aprove / disaprove button

javascriptdialogtoastr

提问by Marc Rasmussen

I am trying to setup Toastr js to become sortof a dialog button.

我正在尝试将 Toastr js 设置为某种对话框按钮。

All i need is an "Approve" and a "Disaprove" button on my Toastr message

我所需要的只是 Toastr 消息上的“批准”和“拒绝”按钮

toastr.options = {
    "closeButton": true,
    "debug": false,
    "positionClass": "toast-bottom-left",
    "onclick": null,
    "showDuration": "1000",
    "hideDuration": "1000",
    "timeOut": "5000",
    "extendedTimeOut": "1000",
    "showEasing": "swing",
    "hideEasing": "linear",
    "showMethod": "fadeIn",
    "hideMethod": "fadeOut"
}
toastr.info("Do you wish to continue");

Does anyone know if that is possible or know any other script that allows me to?

有谁知道这是否可行或知道任何其他允许我这样做的脚本?

Please note

请注意

I know this can be done with Modal but i want to try and avoid it.

我知道这可以用 Modal 来完成,但我想尽量避免它。

回答by John Papa

Sure. You can add any HTML you want to the toast then hook up event handlers to it. See the demo for more details and examples. http://codeseven.github.io/toastr/demo.html

当然。您可以向 toast 添加任何您想要的 HTML,然后将事件处理程序连接到它。有关更多详细信息和示例,请参阅演示。http://codeseven.github.io/toastr/demo.html

回答by Adi Ep

You can add buttonsfor toastr js.

您可以为 toastr js添加按钮

For example a button for okis clicked to clear the toastr:

例如,ok单击按钮以清除toastr

toastr.info('message <button type="button" class="btn clear btn-toastr" onclick="toastr.clear()">OK</button>' , 'Studio Message:');