Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option class passthrough for multi-select #2923

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions coffee/chosen.jquery.coffee
Expand Up @@ -310,6 +310,8 @@ class Chosen extends AbstractChosen
close_link = $('<a />', { 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

Expand Down
2 changes: 2 additions & 0 deletions coffee/chosen.proto.coffee
Expand Up @@ -302,6 +302,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 }

Expand Down
1 change: 1 addition & 0 deletions coffee/lib/abstract-chosen.coffee
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions public/options.html
Expand Up @@ -60,6 +60,11 @@ <h3>Example:</h3>
<td>false</td>
<td>When set to <code class="language-javascript">true</code>, Chosen will grab any classes on the original select field and add them to Chosen’s container div.</td>
</tr>
<tr>
<td>inherit_option_classes</td>
<td>false</td>
<td>When set to <code class="language-javascript">true</code>, Chosen will grab any classes on the original option tags and add them to Chosen’s container li.</td>
</tr>
<tr>
<td>max_selected_options</td>
<td>Infinity</td>
Expand Down