How to access view model data in jquery?


How to access view model data in jquery?



In my html, I use Model.Subcontract.company

How can I reference that data in my jQuery?


Dynamic content in static content

1:

Id with / causes problems with routing [duplicate]
Set the value to an html element and then access it via jquery.. How to define route & controller structure for 2 controllers?
<input type="hidden" value="<%= Model.Subcontract.Company %>" id="hidData" name="hidData" />  $("#hidData").val(); 
ASP.NET MVC - HTML.BeginForm and SSLasp.net mvc IDataErrorInfo validation when using ViewModel

2:

How to make data available when one Controller's View calls another Controller's View?
This is an effective way to reference the model as an object in jQuery:. Is WPF and MVC same concepts?
var model = @Html.Raw(Json.Encode(Model)) 
If you want to avoid the harmless, intellisense error:. jQUERY onclick post
var model = [@Html.Raw(Json.Encode(Model))][0]; 

3:

I was able to did it like this:.
"<%= Model.Subcontract.company %>" 
It's always easier to figure it out after you've given up and asked the question!.


69 out of 100 based on 44 user ratings 679 reviews

#