HREF not copied to ok button - Bootstrap Confirmation

454 views Asked by At

I'm trying to get bootstrap-confirmation.js to work for a delete dialog.

The problem I'm having is I can't get it to copy the href to the ok button. It always just puts "#" as the href.

Here's my code:

    <html>
    <head>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/js/bootstrap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-confirmation/1.0.5/bootstrap-confirmation.js"></script>
    </head>

    <body>
    <a href="https://google.com" target="_blank" data-toggle="confirmation"  data-title="Delete?" class="btn btn-primary">Delete</a>
    <script>
        $('[data-toggle=confirmation]').confirmation({
      rootSelector: '[data-toggle=confirmation]',
      // other options
    });
    </script>
    </body>

You can also see it in action here: https://jsfiddle.net/philsherwood/1sj4ao7e/11/

What am I missing?

1

There are 1 answers

3
AudioBubble On

Js Code:-

$('[data-toggle=confirmation]').confirmation({
  rootSelector: '[data-toggle=confirmation]',
  onConfirm: function() {
    alert("I am Confirmed!!!");
    $('[data-toggle=confirmation]').confirmation('hide');
  },
  popout: true
});

Markup Code:-

 <a href="https://google.com" target="_blank" data-toggle="confirmation"  data-title="Delete?" class="btn btn-primary">Delete</a>

Hope this helps!!!