简体   繁体   English

运行Backbone或Marionette的多个实例

[英]Run multiple instances of Backbone or Marionette

Is it possible to create and run more than one Backbone or Marionette application on the same page at the same time? 是否可以在同一页面上同时创建和运行多个Backbone或Marionette应用程序?

I've tried and I'm only able to get one of the apps to respond correctly to route changes. 我已经尝试过,但是我只能让其中一个应用正确响应路由更改。

I know you can feasible use iframes, but my project would benefit greatly from having the apps run on the same page, sharing the same styles. 我知道您可以可行地使用iframe,但是让应用程序在同一页面上运行,共享相同的样式会极大地受益于我的项目。

Thinking about what could be causing the issue, and Backbone.history springs to mind, but I don't think that would really cause the issues I'm seeing now. 考虑可能是什么导致了该问题,Backbone.history浮现在脑海,但我认为这不会真正导致我现在看到的问题。 In the backbone source, it says that backbone is designed to be able to run without access to a window object, but I'm not so sure. 在骨干资源中,它说骨干被设计为能够在不访问窗口对象的情况下运行,但是我不确定。

Any ideas anyone? 有任何想法吗?

Perhaps you have a Backbone.history.stop & start somewhere in your code. 也许您有一个Backbone.history.stop并在代码中的某个位置开始。 If this is the case, change to Backbone.history.start unless Backbone.History.started 如果是这种情况,请更改为Backbone.history.start,除非Backbone.History.started

It looks like it's possible. 看起来有可能。 I made a jsFiddle with 2 versions of backbone loaded and routers made with each version of BB. 我制作了一个jsFiddle,其中加载了2个版本的骨干网,并且每个BB版本都制造了路由器。 I used backbone.noConflict to use both versions. 我使用了backbone.noConflict来同时使用两个版本。

http://jsfiddle.net/6YSLR/1/ http://jsfiddle.net/6YSLR/1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM