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

[0.9.4] Data binding works only for "id" attribute? #1633

Closed
miriti opened this issue May 27, 2015 · 3 comments
Closed

[0.9.4] Data binding works only for "id" attribute? #1633

miriti opened this issue May 27, 2015 · 3 comments

Comments

@miriti
Copy link

miriti commented May 27, 2015

I'm trying to bind a computed property to different attributes on different elements. But it works only for "id" attributes. Is it the way it should be? I couldn't find anything about it in the documentation. Or I'm doing something wrong? Here is a reduced case:
http://miriti.github.io/polymer-case/
If you'll "Inspect" those elements you will that only "id" attributes are set as expected. Also other attributes that was bound disappeared!

Code:

<dom-module id="test-element">
    <template>
    <div class="{{computedID('value')}}">DIV</div>
    <p data-id="{{computedID('value')}}">P</p>
    <button id="{{computedID('value')}}">BUTTON</button>
    <a id="{{computedID('value')}}">A</a>
    </template>
</dom-module>

<test-element></test-element>

<script>
Polymer({
    is: 'test-element',
    seed: 293472,
    computedID: function(someval) {
        return this.seed + '_' + someval;
    }
});
</script>

http://miriti.github.io/polymer-case/

@Sleeckx
Copy link

Sleeckx commented May 27, 2015

@miriti
Copy link
Author

miriti commented May 27, 2015

Oh! I'm really sorry for my inattentiveness!
But why it works for "id" attributes?

@sorvell
Copy link
Contributor

sorvell commented May 27, 2015

id is also a property so binding to it as a property works.

You will need to use $= to bind to class or data-*.

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

4 participants