Fix selectize initialization when the project has 0 existing tags.

This commit is contained in:
Pēteris Caune 2020-03-09 14:39:03 +02:00
parent 26ad94d068
commit ab692236eb
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2

View File

@ -7,7 +7,12 @@ $(function () {
}); });
// Configure Selectize for entering tags // 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({ $("#update-tags-input").selectize({
create: true, create: true,
createOnBlur: true, createOnBlur: true,
@ -16,7 +21,7 @@ $(function () {
searchField: ["value"], searchField: ["value"],
hideSelected: true, hideSelected: true,
highlight: false, highlight: false,
options: allTags.map(function(tag) { return {value: tag} }) options: options
}); });
$("#new-check-alert a").click(function() { $("#new-check-alert a").click(function() {