在我的主干应用程序中,我在父 View 中创建一个弹出窗口并将其添加到 DOM,如下所示
afterRender: function() {
this.$el.append(
new Popover.Views.Default({
stick:'right',
offsetTop: 3,
offsetRight: 5,
content: "Foo",
reference: this.$el
}).render().$el
);
},
toggle: function(){
app.vent.trigger('popover34:toggle');
}
但是,弹出窗口会附加到其父 View 。父 View 是一个链接,这会导致弹出窗口中出现一些 CSS 问题。
我的问题是,这样做是否安全:
afterRender: function() {
$('body').append(
new Popover.Views.Default({
stick:'right',
offsetTop: 3,
offsetRight: 5,
content: "Foo",
reference: this.$el
}).render().$el
);
}
或者有没有办法将其设置在父 View 旁边?问题是,当我切换弹出窗口时,它将多次添加到 DOM 中。
最佳答案
第二个(并希望澄清)艾萨克在这里的答案,您的“父” View 应该位于一个区域,Popover
View 应该位于另一个区域。
Brian Mann 做了 excellent set of videos关于 Marionette.js 和良好的应用程序设计,one specifically that demonstrates your exact scenario .
祝你好运, 亚伦
关于javascript - 在 Backbone.js 应用程序的 DOM 中将 subview 附加到父 View 之外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17493704/