In my Razor markup, I am looping through my model collection and outputting table rows. Currently, I am storing the the item ID’s in each table row’s “data-id” attribute. I am needing to store the entire object per row though so it will save me some future ajax calls. What is a good way to store the full object per row on the Razor output for my jQuery to use later?
In my Razor markup, I am looping through my model collection and outputting table
Share
Have you considered using something like Knockout.js or any other model-based template Javascript language (there’s plenty, including Backbone, Angular, etc)? You could simply bind your whole model to Javascript (serialize it to JSON). You could then use a template to generate the table. This is the best advice I can give you.
If you want a quick/hack-ey way, you could always do something like: