简体   繁体   English

主干木偶多个实例未呈现javascript

[英]Backbone Marionette Multiple instance not rendering javascript

I'm trying to render two instances of an ItemView into different regions. 我正在尝试将ItemView的两个实例渲染到不同的区域。 When I do this, only one region appears with the working javascript. 当我这样做时,只有一个区域会显示正常的javascript。 Both instances have their html elements. 这两个实例都有其html元素。

I have two files that are both Layouts. 我有两个都是布局的文件。 One calls 一个电话

 var monthView = new CalendarView({ parentDivName: "full_screen" });
 App.mainRegion.show(monthView);

The other calls: 其他电话:

  var monthView2 = new CalendarView({ parentDivName: "full_screen22" });
  App.datePickerRegion.show(monthView2);

Does anyone have a fiddle they can share where two instances of an ItemView are rendered on the same page where the javascript within the ItemView can be visible? 没有人能摆弄小玩意儿,他们可以共享在同一页面上呈现ItemView中的javascript的同一页面上呈现ItemView的两个实例的地方吗? Or, am I going about this all wrong? 还是我要把这全部弄错? Is there a better way to create multiple instances of the same ItemView? 有没有更好的方法来创建同一ItemView的多个实例?

I imagine the problem lies elsewhere in your code as this is both valid code and a valid approach to rendering multiple instances of an ItemView. 我认为问题出在代码的其他地方,因为这既是有效代码,又是呈现ItemView多个实例的有效方法。 Without more code, it will be hard to figure out what exactly is the problem. 没有更多的代码,将很难弄清楚到底是什么问题。 One thing to check is that the layout has been rendered before trying to render something in one of its regions. 要检查的一件事是,在尝试在其区域之一中渲染某些内容之前,已经渲染了该布局。 Here's a simple jsfiddle that demos what I think you're going for: http://jsfiddle.net/craigjennings11/jxu9j/ 这是一个简单的jsfiddle,它演示了我认为要使用的功能: http : //jsfiddle.net/craigjennings11/jxu9j/

var Layout = Backbone.Marionette.Layout.extend({
    el: '.layout',
    template: _.template('<div class="view1"></div><div class="view2"></div>'),
    regions: {
        view1: '.view1',
        view2: '.view2'
    }
});

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

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