Way to Check if Current Form is Nested in Template?

44 views
Skip to first unread message

Zac Gross

unread,
Nov 26, 2013, 8:39:09 PM11/26/13
to backbon...@googlegroups.com

Hi,

I am trying to modify the included bootstrap form template to show a submit button when a "submitbtn" flag is set in the templateData field. 

The problem is the button is repeated on nested models (fields with schema type "NestedModel"), is there a way to check if the current form is nested with template markup?


Something like the following:
e.g.

/**
   * Bootstrap templates for Backbone Forms
   */
  Form.template = _.template('\
    <div>\
    <form class="form-horizontal" data-fieldsets>\
    </form>\
    <% if(submitbtn && !nestedModel) { %>\
      <button class="btn btn-primary" id="createTagBtn">Submit</button>\
    <% } %>\
    </div>\
  '); 

(Additionally because of this the current bootstrap templates generate nested <form> tags which are not valid html)


Thanks,
Zac
Reply all
Reply to author
Forward
0 new messages