sweh / ajja

JavaScript library for simple creation of forms and display of collections
MIT License
2 stars 0 forks source link

Make it possible to write widget templates inside the form template #52

Open florianpilz opened 8 years ago

florianpilz commented 8 years ago

A great addition to ajja would be to describe a template for a single field inline, i.e. inside the form template like this (field-custom):

<script id="form-template" type="text/x-template">
    <form method="POST" action="{{action}}" id="{{form_id}}">
      <div id="field-subject"></div>
      <div id="field-body"></div>
      <div id="field-custom">
        <textarea cols="80" rows="15" data-bind="value: {{name}}" name="{{name}}"></textarea>
      </div>
    </form>
</script>

This way I avoid the overhead to define a template and to define it's use for field-custom inside the options by expressing it via the HTML structure. This would be a burden for a template that is used just once.

Of course, if I want to reuse the template, it must be extracted from the form.