From f72f46962ea17cd180157670e54f6b283770429e Mon Sep 17 00:00:00 2001 From: doocal Date: Wed, 6 Sep 2017 22:26:17 +0800 Subject: [PATCH] Update dialog.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 解决在弹出页添加按扭,刷新页面时按扭事件多次绑定的问题。 --- src/dialog.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/dialog.js b/src/dialog.js index a14431d..6fdf21a 100644 --- a/src/dialog.js +++ b/src/dialog.js @@ -389,20 +389,18 @@ $.extend(prototype, { val.value + ''; - that._$('button') - .on('click', '[i-id=' + id + ']', function(event) { - var $this = $(this); - if (!$this.attr('disabled')) { // IE BUG - that._trigger(id); - } - - event.preventDefault(); - }); - }); } - this._$('button').html(html); + this._$('button').html(html).off('.art.button').on('click.art.button', '[i-id]', function (event) { + var $this = $(this), + id = $this.attr("i-id"); + if (!$this.attr('disabled')) {// IE BUG + that._trigger(id); + } + + event.preventDefault(); + }); this._$('footer')[number ? 'show' : 'hide'](); return this; @@ -467,4 +465,4 @@ artDialog.defaults = defaults; -module.exports = artDialog; \ No newline at end of file +module.exports = artDialog;