【问题标题】:BackboneJS, MarionetteJS - Trying to display layout + regionsBackboneJS,MarionetteJS - 试图显示布局 + 区域
【发布时间】:2013-04-11 06:32:53
【问题描述】:

我有以下代码

$ ->

  class MainLayout extends Marionette.Layout
    template: Handlebars.compile $("#main_layout_hb").html()

    regions:
      header    : "#header"
      options   : "#options"
      footer    : "#footer"


  class MainRegion extends Marionette.Region
    el:"#main_wrap"

  class App extends Marionette.Application

    main_region : new MainRegion
    main_layout : new MainLayout

    onStart: =>
      @main_region.show(@main_layout)

      # start the backbone history for URL routing
      if Backbone.history
        Backbone.history.start()


  app = new App
  app.start()

我正在尝试遵循此页面上的示例https://github.com/marionettejs/backbone.marionette/wiki/The-relationship-between-regions-and-layouts

但是当我运行代码时,我没有将模板“#main_layout_hb”插入到区域中。那里发生了什么?

【问题讨论】:

    标签: backbone.js coffeescript marionette


    【解决方案1】:

    您应该使用 addRegions 方法创建应用的区域:

    App.addRegions
        main_region: "#main_wrap"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-09
      • 1970-01-01
      • 2013-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-24
      相关资源
      最近更新 更多