-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Dynamically Added Select2 does not perform Ajax call #6028
Copy link
Copy link
Closed
Description
I need to dynamically add a select2 with an ajax call to my asp.net mvc view. The control adds and displays, but it does not make the ajax call:
` $('#divEmployee').append('<label>Employees:</label><select id="reqEmployee" class="form-control" name ="reqEmployee" multiple ></select >')`
$('#reqEmployee').select2({
width: "100%", placeholder: 'Select an Employee', ajax: ({
url: "@Url.Action("EmployeeSearch", "Lookup", new { area = "" })", data: function (params) { return { term: params.term, all: !$('#ActiveOnly').is(":checked"), nameAsVal: false, fullName: true, ecid: true } }, delay: 250, dataType: 'json',
processResults: function (data) { return { results: data } }
}), minimumInputLength: 2
}).trigger('change');
$('#reqEmployee').on('change', function () {
var value = $('#reqEmployee').val();
$('#Employees').val(value);
});`
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels