Search code examples
javascriptjquerybackbone.jsmarionettebackbone-views

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


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



            });

        })

Solution

  • 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