diff --git a/static/js/checks.js b/static/js/checks.js index abf8f631..907ba46e 100644 --- a/static/js/checks.js +++ b/static/js/checks.js @@ -7,7 +7,10 @@ $(function () { $("#update-name-form").attr("action", url); $("#update-name-input").val(this.dataset.name); + + var tagsSelectize = document.getElementById("update-tags-input").selectize; tagsSelectize.setValue(this.dataset.tags.split(" ")); + $("#update-desc-input").val(this.dataset.desc); $('#update-name-modal').modal("show"); $("#update-name-input").focus(); @@ -234,6 +237,10 @@ $(function () { }); // Configure Selectize for entering tags + function divToOption() { + return {value: this.textContent}; + } + $("#update-tags-input").selectize({ create: true, createOnBlur: true, @@ -241,12 +248,8 @@ $(function () { labelField: "value", searchField: ["value"], hideSelected: true, - highlight: false - }); - - var tagsSelectize = document.getElementById("update-tags-input").selectize; - $("#my-checks-tags div").each(function(idx, el) { - tagsSelectize.addOption({value: el.textContent}); + highlight: false, + options: $("#my-checks-tags div").map(divToOption).get() }); }); diff --git a/static/js/details.js b/static/js/details.js index 014860a0..45dd76aa 100644 --- a/static/js/details.js +++ b/static/js/details.js @@ -7,12 +7,7 @@ $(function () { }); // Configure Selectize for entering tags - var options = []; var allTags = $("#update-tags-input").data("all-tags").split(" "); - for (var i=0, tag; tag = allTags[i]; i++) { - options.push({value: tag}); - } - $("#update-tags-input").selectize({ create: true, createOnBlur: true, @@ -21,7 +16,7 @@ $(function () { searchField: ["value"], hideSelected: true, highlight: false, - options: options + options: allTags.map(function(tag) { return {value: tag} }) }); $("#new-check-alert a").click(function() {