I would like to access ViewBag data from within client side code. This is what I've tried in my controller:
ViewBag.Tasks = new JavaScriptSerializer().Serialize(tasks);
In my view I would then put this in a hidden field so that it available client side:
<input type="hidden" name="diagramData" data-nodes="@ViewBag.Tasks" />
In my Javascript file, I would then search for the info related to the selected node:
alert($("#diagramData").data("nodes")); //?????
The alert always shows "undefined". Why is this?