I have tried it like that but the JS function doesn't invoke
initial:
@{
List<CmsSite.Models.Category> category_list = (List<CmsSite.Models.Category>)ViewData["categories_details"];
}
pass to js function:
<button onclick="InsertNewProduct(@Json.Encode(category_list))">Save</button>
js function:
function InsertNewProduct(arr) {
json_obj = {
//what to do here
}
now arr is an array of JSON objects
I can't see the List<CmsSite.Models.Category> category_list values
How should I decode this on JS?