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

Feature: array variable accessor #1849

Closed
masaoliou opened this issue Jun 12, 2015 · 2 comments
Closed

Feature: array variable accessor #1849

masaoliou opened this issue Jun 12, 2015 · 2 comments

Comments

@masaoliou
Copy link

I need to bind path using variable as subscript to access array like this:

<template is="dom-repeat" items="[[fields]]" as="field" index-as="i">
    <paper-input bind-value="{{row.i}}"></paper-input>
</template>
@masaoliou masaoliou changed the title Supporting array variable accessor feature: Supporting array variable accessor Jun 12, 2015
@masaoliou masaoliou changed the title feature: Supporting array variable accessor Feature: array variable accessor Jun 12, 2015
@masaoliou
Copy link
Author

Please note that fields``androw` are associated by index. That is why two arrays instead of just one are created.

<template is="dom-repeat" items="[[fields]]" as="field" index-as="i">
    <paper-input label="[[field]]" bind-value="{{row.i}}"></paper-input>
</template>

@masaoliou
Copy link
Author

At this moment, I probably can borrow the technique introduced by @kevinpschaaf in issue #1854 in order to propagate data to paper-input, and implement call back on-value-changed for paper-input to update data according to the property value of paper-input. That is, some awkward and untested code like this:

<template is="dom-repeat" items="[[fields]]" as="field" index-as="i">
    <paper-input label="[[field]]" value="{{columnValue(row.*,i)}}" data-index="[[i]]" on-value-changed="updateModel"></paper-input>
</template>

columnValue:function(row,index){
    return row.base[index];
},
updateModel:function(e){
    this.row[e.target.getAttribute("data-index")]=e.target.value;
}

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

1 participant