I have a JavaScript function that I need to run. It takes some parameters. The actual parameters are in a collection in my view model. This JavaScript function needs to be called as many times as there are elements in the collection, with the elements of the collection as the respective parameters each time.
This function needs to be called when the document loads. So, I thought I should put the calls to this function in document.ready. The problem is that I don’t know how to loop through my C# collection and generate Javascript at the same time. Do you know how I can achieve this? Any help would be greatly appreciated.
You can serialize your view model to JSON and render it inside script block in your view: