chaplinjs / chaplin

HTML5 application architecture using Backbone.js
http://chaplinjs.org
Other
2.85k stars 232 forks source link

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

Closed szelga closed 9 years ago

szelga commented 9 years ago

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.

szelga commented 9 years ago

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.

szelga commented 9 years ago

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