From a4780b85f4723758e89d5af64f17566d31777e4d Mon Sep 17 00:00:00 2001 From: Rafael Xavier de Souza Date: Mon, 26 Nov 2012 10:58:03 -0200 Subject: [PATCH] Trigger "change" event after changing this.value = fb.color --- farbtastic.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/farbtastic.js b/farbtastic.js index a609eec..c36eac4 100644 --- a/farbtastic.js +++ b/farbtastic.js @@ -6,6 +6,8 @@ */ (function($) { +var triggerChangeDelay = 200; + $.fn.farbtastic = function (options) { $.farbtastic(this, options); return this; @@ -190,7 +192,14 @@ $._farbtastic = function (container, callback) { // Change linked value $(fb.callback).each(function() { if (this.value && this.value != fb.color) { + var element = $(this); this.value = fb.color; + if(fb.triggerChange) { + clearInterval(fb.triggerChange); + } + fb.triggerChange = setTimeout(function() { + element.trigger("change"); + }, triggerChangeDelay); } }); }