In my view model I have a dictionary that I want to evaluate in a jQuery function. I'm having a tough time mapping between the two languages.
View Model
public Dictionary<int, string> Collection { get; set; }
Script
$("#someButton").click(function () {
var collection = {};
var count = '@(Model.Collection.Count)' * 1;
for (var i = 0; i < count; i++) {
collection[i] = // Model.Collection[i]
}
...
});
How do I either retrieve values by index directly from my view model's Collection property, or fill a local javascript array with that data so that I can operate on the copy in my function?
I've read a little about Knockout and Json.NET but I'm really hoping to avoid yet another dependency/learning curve in my project.