Skip to content

Commit e564260

Browse files
committed
#290 prevent multiple attachments
1 parent 97f4a4c commit e564260

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

js/jquery-confirm.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ var jconfirm, Jconfirm;
2929
*/
3030
$(this).each(function () {
3131
var $this = $(this);
32+
if ($this.attr('jc-attached')) {
33+
console.warn('jConfirm has already binded to this element ', $this[0]);
34+
return;
35+
}
36+
3237
$this.on('click', function (e) {
3338
e.preventDefault();
3439
var jcOption = $.extend({}, options);
@@ -49,8 +54,10 @@ var jconfirm, Jconfirm;
4954
};
5055
}
5156
jcOption['closeIcon'] = false;
52-
$.confirm(jcOption);
57+
var instance = $.confirm(jcOption);
5358
});
59+
60+
$this.attr('jc-attached', true);
5461
});
5562
return $(this);
5663
};
@@ -1324,10 +1331,8 @@ var jconfirm, Jconfirm;
13241331
$(window).on('keyup', function () {
13251332
keyDown = false;
13261333
});
1327-
13281334
jconfirm.lastClicked = false;
13291335
$(document).on('mousedown', 'button, a', function () {
1330-
console.log('hey clicked', this);
13311336
jconfirm.lastClicked = $(this);
13321337
});
13331338
})(jQuery, window);

0 commit comments

Comments
 (0)