I’m using knockout.js in my asp.net mvc project I have javascript
code
<script type="text/javascript">
var model = "@Html.Raw(Json.Encode(Model))";
$.get("@Url.Action("_CityPartial")" ...)
</script>
How to transfer this javascript code in a separate js file.
Please solve this problem as soon as
Thanks in advance
Anonymous User
26-May-2015You can create external .js file with your code in and pass your serialized json object to it like this:
This has the benefits of keeping the main body of javascript in a separate file.
Any other razor variables can be passed across to the methods defined in the javascript in the same manor as the model has been above.