Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically added paper-button is not rendered correctly

I have the following html:

  <paper-button raised>Static</paper-button>
  <script>
    var button = document.createElement('paper-button');
    button.textContent = "dynamic";
    button.raised = true;
    document.body.appendChild(button);
  </script>

If I add the paper-button statically, it renders normally, but I have do allmost the exact same thing dynamically, I don't get any animations.

Is there something special I need to do if I add the paper-button dynamically ?

see: http://jsbin.com/rararurotu/1/edit?html,output

like image 554
Kasper Avatar asked Feb 12 '26 14:02

Kasper


1 Answers

You need to set the textContent using the Polymer.dom api.

The following code will work:

<paper-button raised>static</paper-button>
<script>
  var button = document.createElement('paper-button');
  button.raised = true;
  Polymer.dom(button).textContent = 'dynamic';
  document.body.appendChild(button);
</script>

see: http://jsbin.com/gexifaxaqi/1/edit?html,output

like image 158
Kasper Avatar answered Feb 14 '26 03:02

Kasper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!