Reputation: 2003
I have a text box which I am trying to add a "search assist" type effect onto, which displays the top then things in the list of items depending on what the user is typing, the problem is, I have a list of names in my Users model and I am trying to create the search assist in Javascript, is there an easy way to use the models in JavaScript? or perhaps there might be another way that I could look into?
Upvotes: 0
Views: 42
Reputation: 22619
Yes you can do it by converting your viewmodel to JSON, then use the js object.
<script type="text/javascript">
var myJSModel= @Html.Raw(Json.Encode(myViewModel));
</script>
Upvotes: 1