Scenario:
A partial view has a model, I need to use the value from the model in the javascript which is in seperate .js file.
Currently, I'm using javascript inline so that the value in the model can be used, but what if, the javascript is moved to a seperate file. In this case how do I get those values.
Code
@model IEnumerable<BookSpec.DomainEntities.ContactModel.ContactDataModel>
<label for="SpecFinder">Contact</label>
<select id="SpecFinder" name="state">
@foreach (var name in Model)
{
<option value="@name.GroupID">@name.GroupName</option>
}
</select>
<script type="text/javascript">
$(document).ready(function () {
$("#SpecFinder").change(function(){
getData(this.value,'@Model.ProductID');
});
})
</script>
This is my current example code looks like, and I want to completely move the inline javascript to a seperate file. How can I do it, I also need the values from the model.
data-productidattribute of the element