javascript - Marionette 中布局内的布局

标签 javascript backbone.js marionette

我有两种布局,例如:

Layout1 = Marionette.Layout.extend({
  template: {
  type: 'handlebars',
  template: Layout1template
},
  regions: {
  region1: '#header',
  region2: '#content'
}

});

Layout2 = Marionette.Layout.extend({
template: {
  type: 'handlebars',
  template: Layout2template
},
  regions: {
  region1: '#contenttop',
  region2: '#contentbottom'
}

});

我想在Layout1的region2中添加Layout2。或者我想将布局嵌套在布局内。任何帮助将不胜感激。

最佳答案

布局直接从 ItemView 扩展,因此在 marionette 中创建嵌套布局是无缝的。

在 Layout1 的 onRender 中,您应该有以下代码:

onRender: function(){
  this.region2.show(new Layout2({
    ...//code here
  }));
}

关于javascript - Marionette 中布局内的布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20391684/

相关文章:

jquery-mobile - jQuery Mobile 与 Marionette 或 Chaplin?

javascript - 密码 : "Atleast 1 letter, 1 number, 1 special character and SHOULD NOT start with a special character" 的正则表达式

javascript - 使用 array.splice() 来洗牌牌组数组时卡住了

javascript - 将 Chrome 扩展程序 popup.html 页面重定向到 Oauth 的 URL

javascript - 主干restful api服务器返回

javascript - 主干保存嵌套集合

javascript - "more/less"切换内容

backbone.js - 如何重新格式化 Backbone 模型项目

jquery - 在单页应用程序中处理 MySql 数据库的最佳方法是什么?

backbone.js - 复杂主干应用程序中的事件管理