I have this in my viewModel.
public IEnumerable<TeamDto> Teams { get; set; }
And, in my view:
<input name="Teams" id="Teams" [email protected] />
How do I access the team list in jQuery?
var data2 = $("#Teams")??
I have this in my viewModel.
public IEnumerable<TeamDto> Teams { get; set; }
And, in my view:
<input name="Teams" id="Teams" [email protected] />
How do I access the team list in jQuery?
var data2 = $("#Teams")??
You access the value of an input by using the val() method. You can also set the value with val('your value')
var data2 = $("#Teams").val();
val function will return the inputs value but you need to consider what format it's in, possibly JSON.parse (or the jQuery equivalent) it to get data JavaScript can use.@Model.Teams to output in json, which I don't know how to do. But I believe that's your issue with accessing the object from javascript.