From 5e4c2803f3977114df793ced9dcf585fada831e9 Mon Sep 17 00:00:00 2001 From: Moritz Kornher Date: Mon, 19 Jan 2015 02:00:20 +1300 Subject: [PATCH] resolves issue #12 https://github.com/josedvq/colpick-jQuery-Color-Picker/issues/12 Call onHide callback when calling colpickHide Signed-off-by: Moritz Kornher --- js/colpick.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/colpick.js b/js/colpick.js index d77432a..d9f8180 100644 --- a/js/colpick.js +++ b/js/colpick.js @@ -250,8 +250,12 @@ For usage and examples: colpick.com/plugin cal.mousedown(function(ev){ev.stopPropagation();}) }, hide = function (ev) { - if (ev.data.cal.data('colpick').onHide.apply(this, [ev.data.cal.get(0)]) != false) { - ev.data.cal.hide(); + var cal = $('#' + $(this).data('colpickId')); + if (ev) { + cal = ev.data.cal; + } + if (cal.data('colpick').onHide.apply(this, [cal.get(0)]) != false) { + cal.hide(); } $('html').off('mousedown', hide); }, @@ -400,7 +404,7 @@ For usage and examples: colpick.com/plugin hidePicker: function() { return this.each( function () { if ($(this).data('colpickId')) { - $('#' + $(this).data('colpickId')).hide(); + hide.apply(this); } }); },