4
votes

Trying to add the submit button dynamically through javascript, below is the code snippet, not sure which attribute to use for setting the text.

      var dynSubmit = document.createElement("paper-button");
      dynSubmit.setAttribute("on-click", "submitForm");
      //dynSubmit.setAttribute("Value", "Submit"); 
      parent.$.iron-form.appendChild(dynSubmit);  

The commented code does not work, How do i set the caption of submit button?

2

2 Answers

4
votes

You can set the button's innerHTML.

Polymer.dom(dynSubmit).innerHTML = "Submit";

Thanks to @jonsS0 for his handy comment.

0
votes

Avoid using innerHTML with Polymer, or at all really; it's slow, it's where XSS can get in, and you shouldn't need it.

Instead use textContent:

dynSubmit.textContent = 'Submit';

You can set this without breaking the ripple and you shouldn't need the Polymer.dom(dynSubmit) as it's an exposed property on the underlying element.