0

私は BackboneForms を使用しており、フィールドセットに渡されたフィールドをいくつかの行でインライン化したいと考えています。(bootstrap3 を使用)

例えば:

form = new Form({
    fieldsets:[
        {legend:'PART1', fields:['title', 'content', 'email']},
        {legend:'PART2', fields:['country', 'sport']}
    ]
});

同じ行に PART1 の入力が必要です。(それぞれの col-sm-4)、PART2 入力の col-sm-6 など、フィールドセット内のオブジェクトの場合。

JsFiddle のコード。

これどうやってするの ?

4

1 に答える 1

0

ドキュメントに従って: https://github.com/powmedia/backbone-forms#customising-templates

カスタムフォーム

<script id="formTemplate" type="text/html">
    <form>
        <h1><%= heading1 %></h1>

        <h2>Name</h2>
        <div data-editors="firstName"><!-- firstName editor will be added here --></div>
        <div data-editors="lastName"><!-- lastName editor will be added here --></div>

        <h2>Password</h2>
        <div data-editors="password">
            <div class="notes">Must be at least 7 characters:</div>
            <!-- password editor will be added here -->
        </div>
    </form>
</script>

Javascript

 var form = new Backbone.Form({
    template: _.template($('#formTpl').html()),
    model: new UserModel(), //defined elsewhere
    templateData: {heading1: 'Edit profile'}
});

プレースホルダは data-xxx 属性です。たとえば、data-fieldsets、data-fields、および data-editors です。

https://github.com/powmedia/backbone-forms#alternate-field-templates

于 2014-12-23T10:28:06.060 に答える