chaplinjs/chaplin

noWrap:true doesn't work properly in subviews when top-level element in template is not div

Closed this issue · 2 comments

subview_template.jade:

tr
  td some text
  td more text

subview.coffee:

View = require 'lib/views/view'

module.exports = class SubView extends View
  noWrap: true
  template: 'subview_template'

mainview_template.jade:

table.table
  thead
    tr
      th some text
      th some text
  tbody.subview

mainview.coffee:

View = require 'lib/views/view'
SubView = require 'subview'

module.exports = class MainView extends View
  template: 'mainview_template'
  regions:
    'subview': '.subview'
  render: ->
    super
    sub_view = new SubView {autoRender: false, region: 'subview'}
    @subview 'sub_view', sub_view
    sub_view.render()

when i render the main view, i get "There must be a single top-level element when using noWrap." error. if i change the top-level element in subview_template to div, it "works" (doesn't properly work, but throws no error). Chaplin 1.0.0, Backbone 1.1.2.

found a workaround: using divs with display: table-row and display: table-cell instead of tr and td but this bug is annoying as hell. and noWrap property is confusing nevertheless.

sorry, my fault. read docs on noWrap once again, and now it's less confusing.