Note that there are some explanatory texts on larger screens.

plurals
  1. POReusable layout for form input controls in emberjs
    primarykey
    data
    text
    <p>I want to create a view layout that I can re-use for multiple kinds of form input controls. For example, all form inputs are going to have:</p> <ul> <li>A label</li> <li>Some kind of input control</li> <li>Help text</li> <li>A placeholder for validation error messages</li> </ul> <p>This is going to be a consistent component throughout the application. The only thing that will change between instances is going to be the input component. It could be, for example, a text field, text area, select, radio buttons, or whatever.</p> <p>It seems like it would be possible to extract this into some kind of template, and just swap out the input control bit:</p> <pre><code>&lt;label {{bindAttr for=view.someId}}&gt;{{view.label}}&lt;/label&gt; {{something-goes-here}} &lt;span class="help-inline"&gt;{{view.help}}&lt;/span&gt; &lt;span class="validation"&gt;{{view.validation}}&lt;/span&gt; </code></pre> <p>I'm not sure if this is even possible though. It looks like a view layout might be the way to go, but for some reason self-closing tags aren't permitted to have layouts, so:</p> <pre><code>{{view Ember.TextField layout=myControlLayout ...}} </code></pre> <p>is out of the question (as a side note, why is this?)</p> <p>Would it be possible to do this using just views? Or would a handlebars helper be more appropriate?</p> <p>My question is very similar to <a href="https://stackoverflow.com/questions/14457217/re-usable-components-views-for-emberjs">this one</a>, but differs in that I want to be able to use my view with <em>any</em> content.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload