Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Creating a Enum based Dropdown in dynamically created HTML inside javascript?

$
0
0

Hi there,

i know how to create a Dropdown (Select) based on Enum inside my Model. But how can i create such a Dropdown in dynamically created HTML code within Javascript because i can not directly access the .Net Core Model stuff.

So this is my Javascript part:

$("#ELEMENT").click( function(){$('#SUB-ELEMENT').append("<div class='col-md-4'>" +"<select class='form-control' id='experience'>" +"<option value='0' selected>Basic</option>" +"<option value='1'>Extended</option>" +"<option value='2'>Professional</option>" +"<option value='3'>Master</option>" +"<option value='4'>Junior</option>" +"</select>" +"</div>"
     );
});

So there the <select> part sould be replaced by something like this, which i use in normale razor code view:

<select asp-for="Model.XXX" asp-items="Html.GetEnumSelectList<Flexibility>()" class="form-control"></select>

How can i do this? Thanks!


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>