how to load html file in Marionette .js + backbone

2020-05-02 08:31发布

I have one "test.html" in that I have this contend (whole html file have this contend).

<h1>First page</h1>

I need to load that contend in my div having id ="contend" using Marionette .js

<div id="contend">


    </div>

could you please tell me how I will do that ? fiddle : 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>',



            });

        })

2条回答
够拽才男人
2楼-- · 2020-05-02 09:06

If you want to show the view by Backbone.router, you just need to pass the Marionette app to router than show it.

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

demo

查看更多
ら.Afraid
3楼-- · 2020-05-02 09:22

Instantiate the view, and show it in the region:

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

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

查看更多
登录 后发表回答