Razor Views und Javascript: An multiSelect anhängen funktioniert nichtJquery

JQuery-Programmierung
Guest
 Razor Views und Javascript: An multiSelect anhängen funktioniert nicht

Post by Guest »

Ich versuche, Optionen an multiSelect anzuhängen. Aber die Daten werden nicht auf der Benutzeroberfläche angezeigt.
Allerdings kann ich die Änderung im DOM durch Chrome-Entwicklungstools sehen.

Code: Select all

 @Html.DropDownListFor(model => model.ProductAndServices,
Model.ProductsAndServices.Select(item => new SelectListItem
{
Value = item.Key.ToString(),
Text = item.Value,
Selected = item.Key == Model.ProductId,
}), htmlAttributes: new { @class = "form-control input-fields-normal dropdown-ie multiSelect", @id = "productAndServicesDDL", @multiple = "multiple", @placeHolder = "Select Products and Services", style = "width:300px; height:300px;" })

$(function () {
$('#productAndServicesDDL').change(function () {

}).multipleSelect({
width: '100%'
});
});
Was ich versuche ist:

Code: Select all

var option = $('')
.attr('value', 199)
.text('Any Service XYZ')
.prop('selected', true);
Es wird versucht, die Optionen anzuhängen

Code: Select all

$('#productAndServicesDDL').append(option).change()

Wenn ich versuche, Folgendes zu verwenden, treten beim multiSelect-Element Ausrichtungsprobleme auf

Code: Select all

$('#productAndServicesDDL').multiselect('refresh');

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post