Ich versuche, Select2 In Rasierer in ASP.NET MVC zu verwenden. Aber ich kann keine Arbeit bekommen.Verwenden Sie Jquery Select2 mit ASP.NET MVC
$(document).ready(function() {
$(".genreOptions").select2({
tags: true,
ajax: {
url: 'http://localhost:65148/NewProfile/Genres',
dataType: 'json',
delay: 250,
data: function (params) {
return {
q: params.term, // search term
page: params.page
};
},
processResults: function (data, page) {
var newData = [];
$.each(data, function (index, item) {
newData.push({
id: item.Id, //id part present in data
text: item.Genre //string to be displayed
});
});
return { results: newData };
},
cache: true
},
escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
minimumInputLength: 1
});
@Html.DropDownListFor(x => x.BandProfile.Genres, Enumerable.Empty<SelectListItem>(), new { @class="genreOptions", multiple = "multiple", style ="width: 100%;"})
Die Suche nach Tags funktioniert gut. Aber wenn ich das Formular poste, ist die Anzahl der Eingabefelder 0. Wie kann ich die Daten aus dem Eingabeformular erfassen?
Ich will nicht das zu tun. Ich möchte hier Rasierer benutzen. – Bryan