JConfirm on Link

650 Views Asked by At

Hi I have an anchor that I am trying to get a JConfirm box to work with, But Its just popping up and disappearing. There is an image in the anchor with an "X"

onclick='jConfirm("Do you really want to do that?.\n ","Import",
    e.preventDefault(); 
    if(!ans) {                                                      
    return false;
     }
});'>
2

There are 2 best solutions below

0
On

This works

$('.deleteconfirm').click(function(e)
                                {
                                link = this;
                                url=link.getAttribute('href')
                                e.preventDefault();
                                jConfirm(("Delete this Report Association?"),'Report',function(confirmed)
                                {
                                    if(confirmed)
                                        {
                                        window.location =url;                                   
                                        }
                                })
                                            });
1
On

try this (untested)... think about what is ans in your code?

jConfirm('Do you really want to do that?', 'Import', function(ans) {
    if(!ans) {                                                      
    return false;
     }
  });

Also it is always cleaner to do this using delegate or on rather than doing inline...