Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Given that setting the layout of an input element is a no-go (I'm not exactly sure why that is either), I suggest you create a view with the layout you want and use it to wrap each input control in your template. The <code>{{yield}}</code> helper marks where your input control will go.</p> <p>Template:</p> <pre><code>&lt;script type="text/x-handlebars" data-template-name="input-control"&gt; &lt;label {{bindAttr for=view.inputId}}&gt;{{view.label}}&lt;/label&gt; {{yield}} &lt;span class="help-inline"&gt;{{view.help}}&lt;/span&gt; &lt;span class="validation"&gt;{{view.validation}}&lt;/span&gt; &lt;/script&gt; </code></pre> <p>View:</p> <pre><code>App.FormElementView = Ember.View.extend({ layoutName: 'input-control', // defaults inputId: '', label: 'Input:', help: 'Enter text above.', validation: '' }); </code></pre> <p>Whenever you introduce an input control, wrap it in this view. Override any defaults you want in the opening <code>{{view}}</code> tag. </p> <pre><code>&lt;script type="text/x-handlebars" data-template-name="index"&gt; {{#view App.FormElementView label="My input:" help="This is where the input goes" inputId="my_input" validationBinding="validation"}} {{input value=value id="my_input"}} {{/view}} &lt;/script&gt; </code></pre> <p>In this case, I mapped the validation string to a computed property in my controller.</p> <pre><code>App.IndexController = Ember.Controller.extend({ value: "", validation: function() { return $.trim(this.get('value')).length &gt; 0 ? 'Looks good.' : 'Type something.'; }.property('value') }); </code></pre> <p><a href="http://jsfiddle.net/ahmacleod/chPAh/" rel="nofollow">Here's the jsfiddle.</a></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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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