Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access/Set an Observer Property With a Dot in the Name #260

Closed
bassmanpaul opened this issue May 13, 2014 · 2 comments
Closed

Access/Set an Observer Property With a Dot in the Name #260

bassmanpaul opened this issue May 13, 2014 · 2 comments

Comments

@bassmanpaul
Copy link

Not sure if a bug or feature request really but I believe the title & my simplified jsFiddle Example explains my predicament.

Basically I am dealing with an extremely large & multidimensional observer object containing folders & files, all of which have dynamic property names.

When it comes to using the Observer setProperty() function, I am struggling to find a way to use this on properties with a dot in the name such as "file.png". This is obviously because when the full stop appears in the set property path JSViews believes it to be a step deeper in the object tree.

Aka:

path.fileWithoutExt.attrs = Works.

path.fileWithExt.png.attrs = Fails.

So my question is "Is there a way to achieve property setting, or is it not possible/feature request/bug?" Could it be something like:

root.path["file.dot"].more
or:
root.path.{{file.dot}}.more

Thanks in advanced for any help!

@BorisMoore
Copy link
Owner

Yes, I just replied on Stack Overflow: http://stackoverflow.com/questions/23608289/access-set-an-observer-property-with-a-dot-in-the-name-in-jsviews.

You can't pass in paths like "object['keyName'].foo" as first parameter of setProperty. (That parameter does expect simply dot-separated paths).

But you don't need to. Just pass the actual object to $.views.observable(...) then you only need to pass the leaf property name to setProperty:

$.observable( files.images[n] ).setProperty( 'modified', 'Modified!' );
$.observable( files.images[n] ).setProperty( 'alias', a ); 

updated jsfiddle: all three work...

@bassmanpaul
Copy link
Author

Legend! Thank you for your time & for developing such a powerful framework. Case closed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants