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

Standalone template binding docs missing? #491

Closed
philipwalton opened this issue May 5, 2014 · 2 comments
Closed

Standalone template binding docs missing? #491

philipwalton opened this issue May 5, 2014 · 2 comments

Comments

@philipwalton
Copy link

The template binding link on the following page points to a missing page:
http://www.polymer-project.org/docs/polymer/databinding-advanced.html#using-data-binding-outside-of-a-polymer-element

So do the two links on this page:
https://github.com/Polymer/TemplateBinding/blob/master/template-instantiation.md

Are there up-to-date docs for using the template binding code outside of a polymer template element?

I'd like to be able to do something like the following:

<root-element>
  <inner-element-control value="{{content}}"></inner-element-control>
  <input-element-output>{{content}}</inner-element-output>
</root-element>

In the above code, content would be a property of <root-element>'s model.

This doesn't seem to be supported in Polymer out of the box.

ebidel added a commit to Polymer/old-docs-site that referenced this issue May 6, 2014
@ebidel
Copy link
Contributor

ebidel commented May 6, 2014

Thanks. Fixed the link.

Examples of using data-binding outside of polymer-element are on http://www.polymer-project.org/docs/polymer/template.html.

Polymer adds two-way data-binding on top of TemplateBinding (one-way). If you want to bind to <root-element>'s .content property, you'll need to wrap everything in another <polymer-element>:

<polymer-element...>
<root-element content="{{content}}">
  <inner-element-control value="{{content}}"></inner-element-control>
  <input-element-output>{{content}}</inner-element-output>
</root-element>
<polymer-element>

Alternatively, if you didn't want to go the element route, you could do something like this outside of <polymer-element>:

<template id="t" if="{{c}}">
  <root-element>
    <inner-element-control value="{{c}}"></inner-element-control>
    <input-element-output>{{c}}</inner-element-output>
  </root-element>
</template>

<script>
document.addEventListener('polymer-ready', function() {
   document.querySelector('#t').model = {
    c: document.querySelector('root-element').content
  };
});
</script>

That example doesn't observe additional changes to rootElement.content, however.

@ebidel
Copy link
Contributor

ebidel commented May 6, 2014

Closing this, as the doc issue is fixed.

@ebidel ebidel closed this as completed May 6, 2014
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