- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在准备使用 Backbone Marionette 迁移我的应用程序,但路由中出现错误:
window.App = new Backbone.Marionette.Application
Models: {}
Collections: {}
Views:
Layouts: {}
Routers: {}
layouts: {}
Helpers: {}
init: ->
App.start()
App.main.show(App.layouts.main)
App.addRegions
main: '#container'
App.addInitializer (options) ->
new App.Routers.Profiles()
Backbone.history.start()
$(document).ready ->
App.init()
class App.Routers.Profiles extends Backbone.Marionette.AppRouter
routes:
'profiles/:id': 'show'
show: (id) ->
@profile = new App.Models.Profile(id: id)
view = new App.Views.ProfilesShow(model: @profile)
@profiles = new App.Collections.Profiles(@profile)
@profile.fetch()
App.layout.content.show(view)
class App.Views.ProfilesShow extends Backbone.Marionette.ItemView
template: JST['profiles/show']
initialize: ->
@model.on('change', @render, @)
render: ->
$(@el).html(@template(profile: @model))
@
class App.Views.Layouts.Main extends Backbone.Marionette.Layout
template: JST['layouts/main']
regions:
content: '#content'
App.addInitializer ->
App.layouts.main = new App.Views.Layouts.Main()
最佳答案
我找到了解决方案。我希望是更好的
主要的变化在路由器,我不得不添加一个 Controller ,所以新的路由器是
class App.Routers.Profiles extends Backbone.Marionette.AppRouter
appRoutes:
'profiles': 'index'
'profiles/new': 'new'
'profiles/:id': 'show'
class App.Controllers.Profiles
constructor: ->
@collection = new App.Collections.Profiles()
@collection.fetch()
App.layouts.main = new App.Views.Layouts.Main()
show: (id) ->
profile = @collection.get(id)
view = new App.Views.ProfilesShow(model: profile)
App.main.show(App.layouts.main)
App.layouts.main.content.show(view)
window.App = new Backbone.Marionette.Application
Models: {}
Collections: {}
Views:
Layouts: {}
Routers: {}
layouts: {}
Helpers: {}
Controllers: {}
init: ->
App.start()
App.addInitializer (options) ->
App.addRegions(main: '#container')
controller = new App.Controllers.Profiles
new App.Routers.Profiles(controller: controller)
Backbone.history.start()
$(document).ready ->
App.init()
关于marionette - Backbone Marionette 路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11999466/
我真的不明白它们是如何有用的。原文article引入了初始化程序,这是代码示例: App = new Backbone.Marionette.Application(); App.addInitial
我正在准备使用 Backbone Marionette 迁移我的应用程序,但路由中出现错误: window.App = new Backbone.Marionette.Application
我正在尝试将 marionette.js 用于我的 Backbone 应用程序,但我对如何组织布局/区域并呈现它们感到有些困惑。 我正在寻找具有嵌套布局和区域的示例应用程序,以便我能更好地理解它。有什
我有一个带有区域的布局。当 Layout 初始化时,我希望它自动初始化一个预设 View 以进入它的区域,并在 Layout 本身显示/关闭时显示/关闭它。 当前示例来自 https://github
//当我点击 kickassessor 按钮时,它会更新数据库,但 View 不会更新。这是我的代码。 返回 Marionette.ItemView.extend( { initialize
我有需要显示/编辑的数据,这些数据似乎与 Marionette 提供的内置 View 不自然。让我举个例子来说明。 假设我想列出/编辑书籍。每本书都有一个 ISBN、一个书名和 0 个或多个标签。基本
我一直在查看各种 Marionette 问题,但没有找到我想要的,希望有人能给我一些合理的建议和一些建议。我是新手,只是想在我在 github 上选择的样板启动包上构建 https://github.
随着我的应用程序的增长,我觉得需要更结构化的路由器/ Controller 设置。 Marionette 文档提到以下内容: It is recommended that you divide you
在我的应用程序中,我添加了 Marionette.sync 插件并覆盖这些方法: Backbone.Marionette.TemplateCache.prototype.loadTemplate =
我想知道是否有可能以某种方式扩展 Marionette Layout 机制基于创建一种类似导航的堆栈。 Marionette 行为。 在区域 show() 的 View 之前,它会在当前显示的 Vie
看起来 Backbone.Marionette View 为事件等操作 DOM,所以我猜这不像更改基类引用那样微不足道,例如Backbone.View 到 BaseView。 有没有人解决过这个问题?
我正在使用 Marionette Layout .show渲染 CollectionView并想知道是否有办法检测 全部 ItemView children 已经完成了渲染? 我的代码的简化版本是:
因此,我不确定我是否完全理解应该如何触发此回调。如果您采用准系统模型、集合和 View : PatchModel = Backbone.Model.extend({}); PatchCollectio
我正在查看 Backbone Marionette,它似乎对我当前的项目很有前途。但是,无论 startWithParent 设置如何,添加模块时它们似乎都会自动启动。这是我遇到问题的一段代码(其中一
我是 Marionette 的新手,无法理解事件... 我有一个触发事件的 ItemView,我想在应用程序级别接收此事件,但是当我的应用程序监听此事件时,没有任何 react ... 如果事件聚合器
我有一个 CollectionView class MyCollectionView extends Backbone.Marionette.CollectionView itemView: My
我有一个复合 View ,在将模型添加到 View 集合时抛出以下错误:Uncaught ItemViewContainerMissingError: Missing itemViewContaine
我已经建立了一个项目,在其中扩展了包含两个不同区域的 Backbone.Marionette.Layout。该布局可以用作整个应用程序的组件。特别是,区域设置如下。 regions : { m
基本上,我试图将 CompositeView 呈现为一个简单的四列列表,其中包含一个表头,其中集合中的每个模型都呈现为一个并附加到 .我正在关注 an example of Derick's非常接近,
我正在尝试包含应用程序实例以使用其事件聚合器,如图所示 here 当我将实例包含在 View 中时,出现错误。 在 Requirejs 配置文件中启动 App.Bootloader.js: requi
我是一名优秀的程序员,十分优秀!