IfnotFr / PopConfirm

A simple action confirmation plugin for jQuery based on Twitter Bootstrap Popover
MIT License
99 stars 35 forks source link

How to combine confirm and ajax #11

Closed laurencei closed 10 years ago

laurencei commented 10 years ago

Hi,

How do I combine the confirm with an ajax request if they accept?

i.e. I have this code

$(".confirm-action").popConfirm();

and I have this code

$('.confirm-action').click(function(e){
            e.preventDefault();
            $.ajax({
                      // Ajax stuff here
            });
});

How do I make it that the ajax only fires if they click accept?

IfnotFr commented 10 years ago

Hi and thanks for using PopConfirm.

What is the actual behaviour of PopConfirm in your case ?

IfnotFr commented 10 years ago

This is an example i wrote using using jquery $.get (similar to $.ajax).

http://jsfiddle.net/FbS5F/

Please do not use e.preventDefault(); where it break the action chain required by PopConfirm triggers.

IfnotFr commented 10 years ago

I close this issue as you did not respond in two weeks :)

I hope that my snippet helps you.