如何在木偶.js+骨干中加载HTML文件

how to load html file in Marionette .js + backbone?

本文关键字:加载 HTML 文件 js+      更新时间:2023-09-26

我有一个"测试.html",因为我有这个争论(整个html文件都有这个争论)。

<h1>First page</h1>

我需要在我的div 中加载该争辩,使用 id ="contend" 木偶.js

<div id="contend">

    </div>

你能告诉我我将如何做到这一点吗?小提琴:http://jsfiddle.net/JQu5Q/16/

   $(document).ready(function(){
            var ContactManager = new Marionette.Application();
            ContactManager.addRegions({
                mainRegion:"#contend"
            })
            ContactManager.on("start", function(){
                console.log("ContactManager has started!");

            });
            ContactManager.start();
         // router 
             var routers =  Backbone.Router.extend({
            routes: {
                "": "showFirstPage"
            },
            showFirstPage:function(){
            }
            })
             var ToolItemView = Backbone.Marionette.ItemView.extend({
                template: '<div>hello</div>',

            });
        })

如果你想通过Backbone.router显示视图,你只需要将木偶应用程序传递给路由器而不是显示它。

var routers = new Router({app: ContactManager})

演示

实例化视图,并在区域中显示它:

var toolItemview = new ToolItemView(); 
ContactManager.mainRegion.show(toolItemview); 

http://jsfiddle.net/JQu5Q/17/