BS Confirm Bug

Using repo from point in time: https://github.com/mistic100/Bootstrap-Confirmation/blob/4e7d382a91ede395deafac585fe082750ecaaffe/bootstrap-confirmation.js

by Sam_Butler

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://rawgit.com/mistic100/Bootstrap-Confirmation/4e7d382a91ede395deafac585fe082750ecaaffe/bootstrap-confirmation.js"></script>
<div id="container" style="padding: 2em;">
  <button id="myButton" type="button" class="btn btn-primary" data-done="no">Button</button>
</div>

JavaScript

$('#myButton[data-done=no]').click(function(){
	$(this).confirmation({
    title: "Shall we do this?"
  });
  $(this).confirmation('show');
});

$('#myButton').on('confirmed.bs.confirmation',function(){
  $('#myButton').attr('data-done','yes');
  var doneState = $('#myButton').attr('data-done');
  $('#container').append('<p>Done state: '+doneState+'</p>');
  $('#myButton').confirmation('dispose');
});

$('#myButton[data-done=yes]').click(function(){
	$(this).confirmation({
    title: "You want to undo this?"
  });
  $(this).confirmation('show');
});