Skip to content
This repository has been archived by the owner on Feb 26, 2019. It is now read-only.

Trigger "change" event after changing this.value = fb.color #6

Open
wants to merge 1 commit into
base: farbtastic-1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions farbtastic.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
(function($) {

var triggerChangeDelay = 200;

$.fn.farbtastic = function (options) {
$.farbtastic(this, options);
return this;
Expand Down Expand Up @@ -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);
}
});
}
Expand Down