Skip to main content
edited title
Link
Toby Caulk
  • 276
  • 2
  • 6
  • 21

Get aan object from a MVC model in JQuery

Source Link
Toby Caulk
  • 276
  • 2
  • 6
  • 21

Get a object from a MVC model in JQuery

I have a DropDownListFor which holds keys from a Dictionary in a class which my MVC Model holds. When I select an item in that list, I would like to then set the text of a TextArea to that corresponding value in the dictionary. To accomplish this, I am trying to use JQuery.

My Issue

It doesn't seem like I can get my dictionary. To get it, I would have to make a call like this:

var fiConfigValues = $('#IdentifiFIConfiguration.Config.Configuration'); 

Where IdentifiFIConfiguration is the model in my ASP.NET MVC View, the Config is a class and the Configuration is the dictionary I am trying to reference.

However, it seems that code does not run, and I also don't know how to convert that var into a Dictionary so I can access the key/value pairs.

My Question

In JQuery, (or even in Razor if there is a way!), how can I access my dictionary that is nested within a couple of classes inside my Model so that I can change the value of my TextArea?