更改函数名称调用中的单击事件

change click event in function name call

本文关键字:单击 事件 调用 函数      更新时间:2023-09-26

我正在尝试自定义默认的删除确认弹出窗口。我正在使用这个插件自定义弹出窗口。在插件中,他们演示了使用按钮onclick。但在我的应用程序中,我在javascript函数中使用了确认对话框

来自插件的实际样本

           $('#button_2').confirmOn({
                questionText: 'This action cannot be undone, are you sure?',
                textYes: 'Yes, I''m sure',
                textNo: 'No, I''m not sure'
            },'click', function(e, confirmed) {
                if(confirmed) $(this).remove();
            });

我尝试在下面自定义确认对话框,

    function deleteFollow(url, obj){
         confirmOn({
                questionText: 'This action cannot be undone, are you sure?',
                textYes: 'Yes, I''m sure',
                textNo: 'No, I''m not sure'
            }, 'click', function(e, confirmed){
  if(confirmed) 
      ''''''''''''
      ajax post comes here
     ''''''''''''''''

上面给出了控制台中的错误为"Uncaught ReferenceError: confirmOn is not defined"。如何实现或更改我的实际功能。

您的第二个confirmOn()没有jQuery前缀:

function deleteFollow(url, obj){
     confirmOn({
            //your code

应该是:

function deleteFollow(url, obj){
     $.confirmOn({
            //your code

或:

function deleteFollow(url, obj){
     $("#foo").confirmOn({
            //your code

尝试您的代码

function deleteFollow(url, obj){
         confirmOn({
                questionText: 'This action cannot be undone, are you sure?',
                textYes: 'Yes, I''m sure',
                textNo: 'No, I''m not sure'
            }, 

更改为

function deleteFollow(url, obj){
         $.confirmOn({
                questionText: 'This action cannot be undone, are you sure?',
                textYes: 'Yes, I''m sure',
                textNo: 'No, I''m not sure'
            },