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

对着背影说爱祢 提交于 2019-12-20 03:53:12

问题


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>',



            });

        })

回答1:


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




回答2:


Instantiate the view, and show it in the region:

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

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



来源:https://stackoverflow.com/questions/28023451/how-to-load-html-file-in-marionette-js-backbone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!