How do I access a strongly typed view of a model inside javascript?
The intellisense support for javascript is a little sketchy as it is. Make sure you set it up correctly. I just used this tutorial and this at least it gives javascript intellisense.
Now, to test your question, I'll just put the following on one of my pages:
<script type="text/javascript">
var test = <%= Model.Site.SiteID %>;
document.write(test);
</script>
and he actually wrote the SiteID. no intellisense for the model, but it does work. hope this helps some.
source to share
Nothing fancy, it's just syntax mixing that the IDE kicks out as you are in a javascript context in an IDE that tries to accommodate the javascript syntax. It probably resets most of the intellisense in this context, because it doesn't know (but hopefully) it <% %>
should be logically equal in javascript. There are a few things you can do to "hack" around this, such as setting up a facade javascript object that reflects the view and returning the object to the view values, although in most cases this is much more than worth it.
source to share