简体   繁体   English

在烤面包机的onShown事件中调用其他函数

[英]call other function in toaster onShown event

I have below code to for toaster 我有以下代码用于烤面包机

    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(){
                hidepanel(); // not working
                this.hidepanel(); // not working
              });
            }
      });

I have one function outside 我外面有一个职能

hidepanel(){
}

When trying to call inside toaster onShown method it throws error 尝试在烤面包机内的onShown方法中调用时会引发错误

hidepanel does not exist on type 'HTMLElement'. hidepanel在“ HTMLElement”类型上不存在。

How can this work? 这怎么工作?

Thanks 谢谢

Assuming you have a function call hidepanel , use the => expression 假设您有一个函数调用hidepanel ,请使用=>表达式

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM