Skip to content

Commit

Permalink
Cancel original event when using delegation (Closes #35)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic100 committed Sep 25, 2016
1 parent 99bd4f8 commit 05c6aff
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bootstrap-confirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,16 @@
}
});
}
else {
// cancel original event
this.$element.on(this.options.trigger, this.options.selector, function(e, ack) {
if (!ack) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
}
});
}

if (!this.options._isDelegate) {
// manage popout
Expand Down
12 changes: 12 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ <h1>Bootstrap Confirmation</h1>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">Delegation</div>
<div class="panel-body" id="confirmation-delegate">
<button class="btn btn-default">Confirmation 1</button>
<button class="btn btn-default">Confirmation 2</button>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">Custom buttons</div>
<div class="panel-body">
Expand Down Expand Up @@ -108,6 +116,10 @@ <h1>Bootstrap Confirmation</h1>
container: 'body'
});

$('#confirmation-delegate').confirmation({
selector: 'button'
});

var currency = '';
$('#custom-confirmation').confirmation({
rootSelector: '#custom-confirmation',
Expand Down

0 comments on commit 05c6aff

Please sign in to comment.