diff --git a/inginious/frontend/static/js/task_dispensers.js b/inginious/frontend/static/js/task_dispensers.js index a0b3a6a54..96ae99b64 100644 --- a/inginious/frontend/static/js/task_dispensers.js +++ b/inginious/frontend/static/js/task_dispensers.js @@ -138,10 +138,8 @@ function dispenser_util_add_tasks_to_section(button) { // Copy and add the new fields var new_modal_clone = $("#edit-modals-template").clone(); new_modal_clone.html(new_modal_clone.html().replaceAll("NEWTASKID", selected_tasks[i])); - new_modal_clone.find(".categories").selectize({delimiter: ",", persist: false, - create: function (input) { return {value: input, text: input}; }, - }); $("#edit-modals").append(new_modal_clone.children(".modal")); + $("#edit-modals").trigger("new_task"); dispenser_add_task(selected_tasks[i]); } } diff --git a/inginious/frontend/templates/course_admin/task_dispensers/config_items/categories.html b/inginious/frontend/templates/course_admin/task_dispensers/config_items/categories.html index d78a72286..b9f20bbe5 100644 --- a/inginious/frontend/templates/course_admin/task_dispensers/config_items/categories.html +++ b/inginious/frontend/templates/course_admin/task_dispensers/config_items/categories.html @@ -30,6 +30,19 @@ $("#edit_" + $(this).data("taskid") + " input.categories").val(value).change(); }); }); + + $(function() { + $("#edit-modals .categories").each(function () { + $(this).selectize({delimiter: ",", persist: false, + create: function (input) { return { value: input, text: input }; } + }); + }); + $("#edit-modals").on("new_task", function () { + $(this).find(".categories").last().selectize({delimiter: ",", persist: false, + create: function (input) { return { value: input, text: input }; } + }); + }); + }); {% endif %} {% endif %} diff --git a/inginious/frontend/templates/course_admin/task_dispensers/util.html b/inginious/frontend/templates/course_admin/task_dispensers/util.html index 1fdf18c04..e063bc063 100644 --- a/inginious/frontend/templates/course_admin/task_dispensers/util.html +++ b/inginious/frontend/templates/course_admin/task_dispensers/util.html @@ -213,19 +213,6 @@

{{ _("Import from course filesystem") }}

}); }); - $("#edit-modals .categories").each(function(){ - $(this).selectize({ - delimiter: ",", - persist: false, - create: function (input) { - return { - value: input, - text: input, - }; - }, - }); - }); - dispenser_util_adapt_viewport(); $(window).on( "resize", dispenser_util_adapt_viewport); });