Jump to content

Javascript References?


Recommended Posts

I have a feeling the answer to this is no (for security reasons) but I'd like to use references in a script I'm writing. I have a JSON object of key-value settings and a set of objects that will take these settings. I would like to be able to update the object and the setting object at the same time without needing to recursively rebuild the setting object every time a value is updated. Here is my example code-

settings:{"fields":{  "sort":  {   "value":1,   "fields":   {	"sort_options":	{	 "value":	 [	  {	   "name":	   {		"value":"test"	   },	   "sort":	   {		"value":"inv_id"	   },	   "sort_direction":	   {		"value":"DESC"	   }	  }	 ]	}   }  },  "pagination":  {   "value":0   "fields":   {	"limit":10   }  }}}

For each of the fields you see (like "sort" and "pagination") in these setting will become an object. Each setting is also sent to a view object that prints an input type to it's parent dom object (like a checkbox or text field). When the field is set and not null then it's sub-fields become visible. So you can see the recursion here. These settings need to be saved to a text file and read in the same format. You can see how it could be convenient to reference that value or any of these fields to the same variable the model is using. Any ideas?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...