From ab692236eb3ae31e6ece295712334c5d89af7cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Mon, 9 Mar 2020 14:39:03 +0200 Subject: [PATCH] Fix selectize initialization when the project has 0 existing tags. --- static/js/details.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/static/js/details.js b/static/js/details.js index 45dd76aa..37789f73 100644 --- a/static/js/details.js +++ b/static/js/details.js @@ -7,7 +7,12 @@ $(function () { }); // Configure Selectize for entering tags - var allTags = $("#update-tags-input").data("all-tags").split(" "); + function toOption(tag) { + return {value: tag} + } + + var allTags = $("#update-tags-input").data("all-tags"); + var options = allTags ? allTags.split(" ").map(toOption) : []; $("#update-tags-input").selectize({ create: true, createOnBlur: true, @@ -16,7 +21,7 @@ $(function () { searchField: ["value"], hideSelected: true, highlight: false, - options: allTags.map(function(tag) { return {value: tag} }) + options: options }); $("#new-check-alert a").click(function() {