Skip to content

Commit 67e4a11

Browse files
committed
Close #58 Add value attribute to custom buttons
1 parent ff64bf0 commit 67e4a11

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed

bootstrap-confirmation.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* Bootstrap Confirmation
33
* Copyright 2013 Nimit Suwannagate <ethaizone@hotmail.com>
4-
* Copyright 2014-2016 Damien "Mistic" Sorel <contact@git.strangeplanet.fr>
4+
* Copyright 2014-2017 Damien "Mistic" Sorel <contact@git.strangeplanet.fr>
55
* Licensed under the Apache License, Version 2.0
66
*/
77

@@ -11,7 +11,9 @@
1111
var activeConfirmation;
1212

1313
// Confirmation extends popover.js
14-
if (!$.fn.popover) throw new Error('Confirmation requires popover.js');
14+
if (!$.fn.popover) {
15+
throw new Error('Confirmation requires popover.js');
16+
}
1517

1618
// CONFIRMATION PUBLIC CLASS DEFINITION
1719
// ===============================
@@ -224,12 +226,12 @@
224226
}
225227

226228
if (button.cancel) {
227-
self.getOnCancel.call(self).call(self.$element);
228-
self.$element.trigger('canceled.bs.confirmation');
229+
self.getOnCancel().call(self.$element, button.value);
230+
self.$element.trigger('canceled.bs.confirmation', [button.value]);
229231
}
230232
else {
231-
self.getOnConfirm.call(self).call(self.$element);
232-
self.$element.trigger('confirmed.bs.confirmation');
233+
self.getOnConfirm().call(self.$element, button.value);
234+
self.$element.trigger('confirmed.bs.confirmation', [button.value]);
233235
}
234236

235237
if (self.inState) { // Bootstrap 3.3.5
@@ -254,7 +256,7 @@
254256
e.preventDefault();
255257
}
256258

257-
self.getOnConfirm.call(self).call(self.$element);
259+
self.getOnConfirm().call(self.$element);
258260
self.$element.trigger('confirmed.bs.confirmation');
259261

260262
self.$element.trigger(self.options.trigger, [true]);
@@ -271,7 +273,7 @@
271273
.one('click', function(e) {
272274
e.preventDefault();
273275

274-
self.getOnCancel.call(self).call(self.$element);
276+
self.getOnCancel().call(self.$element);
275277
self.$element.trigger('canceled.bs.confirmation');
276278

277279
if (self.inState) { // Bootstrap 3.3.5

bower.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "bootstrap-confirmation2",
3-
"version": "2.4.0",
43
"homepage": "http://mistic100.github.io/Bootstrap-Confirmation",
54
"description": "Bootstrap plugin for on-place confirm boxes using Popover",
65
"authors": [

example/index.html

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,30 +125,24 @@ <h1>Bootstrap Confirmation</h1>
125125
rootSelector: '#custom-confirmation',
126126
container: 'body',
127127
title: null,
128-
onConfirm: function() {
128+
onConfirm: function(currency) {
129129
alert('You choosed ' + currency);
130130
},
131131
buttons: [
132132
{
133133
class: 'btn btn-danger',
134134
icon: 'glyphicon glyphicon-usd',
135-
onClick: function() {
136-
currency = 'US Dollar';
137-
}
135+
value: 'US Dollar'
138136
},
139137
{
140138
class: 'btn btn-primary',
141139
icon: 'glyphicon glyphicon-euro',
142-
onClick: function() {
143-
currency = 'Euro';
144-
}
140+
value: 'Euro'
145141
},
146142
{
147143
class: 'btn btn-warning',
148144
icon: 'glyphicon glyphicon-bitcoin',
149-
onClick: function() {
150-
currency = 'Bitcoin';
151-
}
145+
value: 'Bitcoin'
152146
},
153147
{
154148
class: 'btn btn-default',

0 commit comments

Comments
 (0)