From a3c1c245b647074c6e23f800cdc44787a56e9c2a Mon Sep 17 00:00:00 2001 From: Denis Zunke Date: Thu, 12 Apr 2018 11:41:28 +0200 Subject: [PATCH] Add origin value as data-value to built html elements --- coffee/chosen.jquery.coffee | 2 +- coffee/chosen.proto.coffee | 2 +- coffee/lib/abstract-chosen.coffee | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/coffee/chosen.jquery.coffee b/coffee/chosen.jquery.coffee index 7759b3c3fa6..bad9dbe8fba 100644 --- a/coffee/chosen.jquery.coffee +++ b/coffee/chosen.jquery.coffee @@ -318,7 +318,7 @@ class Chosen extends AbstractChosen this.result_clear_highlight() if $(evt.target).hasClass("active-result") or $(evt.target).parents('.active-result').first() choice_build: (item) -> - choice = $('
  • ', { class: "search-choice" }).html("#{this.choice_label(item)}") + choice = $('
  • ', { class: "search-choice", "data-value": item.value }).html("#{this.choice_label(item)}") if item.disabled choice.addClass 'search-choice-disabled' diff --git a/coffee/chosen.proto.coffee b/coffee/chosen.proto.coffee index 19b0ddd83be..f06c90b5159 100644 --- a/coffee/chosen.proto.coffee +++ b/coffee/chosen.proto.coffee @@ -311,7 +311,7 @@ class @Chosen extends AbstractChosen this.result_clear_highlight() if evt.target.hasClassName('active-result') or evt.target.up('.active-result') choice_build: (item) -> - choice = new Element('li', { class: "search-choice" }).update("#{this.choice_label(item)}") + choice = new Element('li', { class: "search-choice", "data-value": item.value }).update("#{this.choice_label(item)}") if item.disabled choice.addClassName 'search-choice-disabled' diff --git a/coffee/lib/abstract-chosen.coffee b/coffee/lib/abstract-chosen.coffee index d0d6e5ed288..258222d66a1 100644 --- a/coffee/lib/abstract-chosen.coffee +++ b/coffee/lib/abstract-chosen.coffee @@ -118,6 +118,7 @@ class AbstractChosen option_el.setAttribute("data-option-array-index", option.array_index) option_el.innerHTML = option.highlighted_html or option.html option_el.title = option.title if option.title + option_el.setAttribute("data-value", option.value); this.outerHTML(option_el)