aboutsummaryrefslogtreecommitdiffstats
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorTeddy Wing2018-04-19 17:23:09 +0200
committerJohan Van Ryseghem2018-04-26 09:16:15 +0200
commitde3762e2db02f876bdd032c9e1afe716d3c25dde (patch)
tree27214218dd318c73208cbb0cb1e35c546293fc52 /app/assets/javascripts
parente5215f229e3dfa5d84a43bcf75e2edf8c99667a3 (diff)
downloadchouette-core-de3762e2db02f876bdd032c9e1afe716d3c25dde.tar.bz2
ReferentialVehicleJourneys: Fix line drop-down placeholder
After adding the `initvalue` data attribute, the placeholder was no longer rendered. Fix this by: 1. Removing all elements from the collection to ensure that boolean options don't get added by default to the select (https://github.com/plataformatec/simple_form/blob/84e4465/lib/simple_form/inputs/collection_input.rb#L36-L41) 2. Not setting an `initSelection` on the Select2 config if the initial selection fields are empty. This finally gets the placeholder to display correctly again. Refs #5889
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/select2.coffee3
1 files changed, 2 insertions, 1 deletions
diff --git a/app/assets/javascripts/select2.coffee b/app/assets/javascripts/select2.coffee
index f34b5d5ce..2ff5e198e 100644
--- a/app/assets/javascripts/select2.coffee
+++ b/app/assets/javascripts/select2.coffee
@@ -28,7 +28,8 @@ bind_select2_ajax = (el, cfg = {}) ->
escapeMarkup: (markup) ->
markup
- if _this.data('initvalue')
+ initValue = _this.data('initvalue')
+ if initValue && initValue.id && initValue.text
cfg["initSelection"] = (item, callback) -> callback(_this.data('initvalue'))
bind_select2(el, cfg)