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>',
});
})
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})
Instantiate the view, and show it in the region:
var toolItemview = new ToolItemView();
ContactManager.mainRegion.show(toolItemview);
来源:https://stackoverflow.com/questions/28023451/how-to-load-html-file-in-marionette-js-backbone