TagBox Custom Widget

Source code: Survey setup
Survey.defaultBootstrapCss.navigationButton = "btn btn-primary";
Survey.Survey.cssType = "bootstrap";
var survey = new Survey.Model({
    pages: [
        { name:"page1", questions: [
            { type: "checkbox", isRequired:true, choicesByUrl: { url: "https://restcountries.eu/rest/v1/all" }, name: "countries", title: "Please select all countries you have been for the last 3 years." }
        ]}
    ]
});


var widget = {
    name: "tagbox",
    htmlTemplate: "<div></div>",
    isFit : function(question) { return question.name == 'countries'; },
    afterRender: function(question, el) {
        var widget = $(el).dxTagBox({
            items: question.visibleChoices,
            value: question.value,
            searchEnabled: true,
            displayExpr: "text",
            valueExpr: "value",
            onValueChanged: function (e) {
                question.value = e.value;
            }
        }).dxTagBox("instance");
        //It requires when choices fills on ajax callback, using choicesByUrl property.
        question.choicesChangedCallback = function() {
            widget.option("items", question.visibleChoices);
        }
        question.valueChangedCallback = function() {
            widget.option("value", question.value);
        }
    },
     willUnmount: function(question, el) {
       $(el).off().remove();
     } 
}
Survey.CustomWidgetCollection.Instance.addCustomWidget(widget);
$("#surveyElement").Survey({
    model: survey
});