Parent properties in MDV?

33 views
Skip to first unread message

Bradley Meck

unread,
Jul 11, 2013, 2:12:11 PM7/11/13
to polym...@googlegroups.com
I have been playing with polymer for a couple of days now and was wondering:

I have a monster farming game with a <monster-picker> that is essentially a <fieldset> of <input type=radio>s, in order to handle single selection of monsters the names of the radio buttons need to be identical. Right now I am denormalizing down, but was wondering if there was a simple way to access parent properties that I was not aware of in MDV. For example:

Given:

```JS
{
  name: "buyable-monsters"
  monsters: [{name:"Billy",breed:"goat"}]
}
```

and

```html
<fieldset name={{name}}>
  <template repeat={{monsters}}>
    {{name}} - {{breed}}<input type=radio name={{../name}}> <!-- should match fieldset -->
  </template>
</fieldset>
```

Becomes:

```html
<fieldset name=buyable-monsters>
  Billy - goat <input type=radio name=Billy>
</fieldset>
```

Erik Arvidsson

unread,
Jul 11, 2013, 2:15:06 PM7/11/13
to Bradley Meck, polym...@googlegroups.com
Take a look at the custom syntax, it allows you to use {{path as name}} and then you can refer to it as {{name}} later on.


--
 
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
Visit this group at http://groups.google.com/group/polymer-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/54022837-3255-4ae6-bf6e-bbb233645a82%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
erik


Daniel Freedman

unread,
Jul 11, 2013, 2:17:05 PM7/11/13
to Bradley Meck, polymer-dev
You can use the Named Scope syntax to accomplish this:

<template repeat="{{monster in monsters}}">
 {{monster.name}} -- {{monster.breed}}<input type-"radio" name="{{name}}" <!-- this name is the top level "name" -->
</template>


--
Reply all
Reply to author
Forward
0 new messages