From 2ca63654c00e816a905fea03ea6e80a89879646a Mon Sep 17 00:00:00 2001 From: Jorge Robles Date: Mon, 9 Mar 2015 11:23:37 +0100 Subject: [PATCH] Allows use data-color on options for fexibility --- jquery.simplecolorpicker.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jquery.simplecolorpicker.js b/jquery.simplecolorpicker.js index ac63238..92eba90 100644 --- a/jquery.simplecolorpicker.js +++ b/jquery.simplecolorpicker.js @@ -59,7 +59,7 @@ // self.$select.find('> option').each(function() { var $option = $(this); - var color = $option.val(); + var color = $option.data('color') || $option.val(); var isSelected = $option.is(':selected'); var isDisabled = $option.is(':disabled'); @@ -159,7 +159,8 @@ } // Change HTML select value - this.$select.val(color); + var opt=this.$select.find('>option[data-color='+color+'] , >option[value='+color+'] '); + this.$select.val(opt.prop('value')); }, /**