The <output>
element provides a semantic way to express that a particular part of the page is related to one or more <input>
s. It can then be used as a target for various JavaScript connections between them.
Currently, as best I can tell, there is no built-in way of asking Rails to render one. Instead I need to manually add the element to my ERb files and associate the for=
attribute by hand.
It would be nice if there was direct support. For example:
<div>
<%= form.label :a_value %>
<%= form.range_field :a_value, value: 5 %>
<%= form.output :a_value %>
</div>
Would render as something like:
<div>
<label for="formname_a_value">A value</label>
<input type="range" name="formname[a_value]" id="formname_a_value" value="5">
<output for="formname_a_value">5</output>
</div>