Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Dynamic keys #54

kwizzn opened this Issue · 2 comments

2 participants


This obviously won't work:

var dynamicDeepKey = 'foo';
model.set({ 'prefix.' + dynamicDeepKey: true });

All I can think of to solve this are hacky solutions like using "prefix.$dynamicDeepKey" as a key and replacing all keys beginning with "$" with something that needs to be provided e.g. in the options map, like so:

model.set({ 'prefix.$dynamicDeepKey': true }, { keys: {
    dynamicDeepKey: 'foo'
} });

Can anyone think of a better idea?


It's slightly more verbose, but how about using []?

var dynamicDeepKey = 'foo',
    objectToSet = {};
objectToSet['prefix.' + dynamicDeepKey] = true;

Straightforward, you're right, @mgevans. I was just wondering if the plugin addresses that issue as well as it does with the array index notation:


@kwizzn kwizzn closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.