diff --git a/coffee/chosen.jquery.coffee b/coffee/chosen.jquery.coffee index 3072fcb861c..42f42fe7921 100644 --- a/coffee/chosen.jquery.coffee +++ b/coffee/chosen.jquery.coffee @@ -334,6 +334,8 @@ class Chosen extends AbstractChosen close_link = $('', { class: 'search-choice-close', 'data-option-array-index': item.array_index }) close_link.on 'click.chosen', (evt) => this.choice_destroy_link_click(evt) choice.append close_link + if @inherit_option_classes && item.classes + choice[0].classList.add item.classes @search_container.before choice diff --git a/coffee/chosen.proto.coffee b/coffee/chosen.proto.coffee index f6873572104..d15c881b6f4 100644 --- a/coffee/chosen.proto.coffee +++ b/coffee/chosen.proto.coffee @@ -345,6 +345,8 @@ class @Chosen extends AbstractChosen close_link = new Element('a', { href: '#', class: 'search-choice-close', rel: item.array_index }) close_link.observe "click", (evt) => this.choice_destroy_link_click(evt) choice.insert close_link + if @inherit_option_classes && item.classes + choice[0].classList.add item.classes @search_container.insert { before: choice } diff --git a/coffee/lib/abstract-chosen.coffee b/coffee/lib/abstract-chosen.coffee index 1a79a5ed5f2..ce1ac024b5c 100644 --- a/coffee/lib/abstract-chosen.coffee +++ b/coffee/lib/abstract-chosen.coffee @@ -30,6 +30,7 @@ class AbstractChosen @single_backstroke_delete = if @options.single_backstroke_delete? then @options.single_backstroke_delete else true @max_selected_options = @options.max_selected_options || Infinity @inherit_select_classes = @options.inherit_select_classes || false + @inherit_option_classes = @options.inherit_option_classes || false @display_selected_options = if @options.display_selected_options? then @options.display_selected_options else true @display_disabled_options = if @options.display_disabled_options? then @options.display_disabled_options else true @include_group_label_in_selected = @options.include_group_label_in_selected || false diff --git a/public/options.html b/public/options.html index c988a844885..c972f0dfd09 100644 --- a/public/options.html +++ b/public/options.html @@ -60,6 +60,11 @@

Example:

false When set to true, Chosen will grab any classes on the original select field and add them to Chosen’s container div. + + inherit_option_classes + false + When set to true, Chosen will grab any classes on the original option tags and add them to Chosen’s container li. + max_selected_options Infinity