change click event in function name call

202 views Asked by At

I am trying to customize the default delete confirm popup.I am using this plugin to customize the popup.In plugin,they demonstrated using button onclick.But in my application i am using confirm dialog box inside the javascript function,

Actual sample from plugin

           $('#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();
            });

I tried in the below to customize the confirm dialog,

    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
     ''''''''''''''''

The above giving the error in console as "Uncaught ReferenceError: confirmOn is not defined ".How to implement or alter the original for my actual function.

2

There are 2 answers

1
hammus On

your second confirmOn() does not have the jQuery prefix:

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

should be:

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

or:

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

try 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'
            }, 

change to

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'
            },