How to dynamically add elements (buttons, input elements) to a page in EmberJS?


This is in JavaScript:

button = document.createElement(“BUTTON”); buttonText = document.createTextNode(“Edit”); button.setAttribute(“name”,name); button.appendChild(buttonText);


Ember takes care of building up elements like that for you, based off what your templates say.

Your example code would just look like:

<button name={{name}}>Edit</button>

in a template. If you want the button to only be present sometimes, you can use a conditional:

{{#if shouldShowButton}}
  <button name={{name}}>Edit</button>