Skip to content

Allow definition of nested model relationships with dotted notation#91

Open
gsxdsm wants to merge 2 commits intoarturadib:masterfrom
gsxdsm:master
Open

Allow definition of nested model relationships with dotted notation#91
gsxdsm wants to merge 2 commits intoarturadib:masterfrom
gsxdsm:master

Conversation

@gsxdsm
Copy link

@gsxdsm gsxdsm commented Aug 13, 2012

Allow definition of nested model relationships with dotted notation:

obj.model.set({person:{name:'John Doe'}})
can now be addressed with 'person.name' in data bindings as well as
obj.model.get('person.name')

Events are also specified with dotted notation
'change:person.name':function(){}

gsxdsm added 2 commits August 12, 2012 19:54
Allow definition of nested model relationships with dotted notation:

obj.model.set({person:{name:'John Doe'}})
can now be addressed with 'person.name' in data bindings as well as
obj.model.get('person.name')

Events are also specified with dotted notation
'change:person.name':function(){}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, we seem to have some indentation issues here - perhaps you're using tabs and not spaces? we use spaces in Agility

@arturadib
Copy link
Owner

This looks good to me, really like those tests. @tristanls ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that this would allow setting a property referenced by an empty string:

data-bind=".oops"

which will try to generate a structure of:

model._data[ '' ] = { oops : 'value' };

This is not a bad thing in itself, and perhaps some future convention can have special meaning for variables ".myFoo" as a result of that, just thinking out loud here.

@tristanls
Copy link
Collaborator

Made a note on code and I'm rusty getting back to ui development, but taking a quick look nothing breaking jumped out.

@golgote
Copy link

golgote commented Nov 4, 2012

What about 'person.addresses.0.street', 'person.addresses.1.street' ?
Or better 'person.addresses[0].street' ?
Maybe something like this too : this.model.get('person.addresses.$.street'), to get all streets for example ?
This can be useful as well, what do you think ?

PS: I'm just starting with Agilityjs. I've tested Backbonejs, Knockoutjs, Angularjs, Emberjs, but Agilityjs is the one that fits my way of programming the best. It's really a clever piece of code, thanks Artur. I hope that you will find more time to take care of it.

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

Successfully merging this pull request may close these issues.

4 participants