如何加载HTML文件中木偶的.js +骨干? [英] how to load html file in Marionette .js + backbone?
本文介绍了如何加载HTML文件中木偶的.js +骨干?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这有一个test.html的我这抗衡(全HTML文件有这样的主张)。
< H1>首先网页< / H1>
我需要加载在我的div抗衡有ID =抗衡使用木偶的.js
< DIV ID =抗衡>
< / DIV>
请你告诉我,我会怎么做呢?
小提琴:
http://jsfiddle.net/JQu5Q/16/
$(文件)。就绪(函数(){
VAR的ContactManager =新Marionette.Application();
ContactManager.addRegions({
mainRegion:#争
}) ContactManager.on(开始,函数(){
的console.log(的ContactManager已经开始了!);
}); ContactManager.start(); //路由器
VAR路由器= Backbone.Router.extend({
路线:{
:showFirstPage
},
showFirstPage:功能(){ }
}) VAR ToolItemView = Backbone.Marionette.ItemView.extend({ 模板:'< DIV>&打招呼LT; / DIV>, }); })
解决方案
如果你想显示由Backbone.router的观点,你只需要木偶应用传递到路由器不是显示它。
VAR路由器=新路由器({应用:为ContactManager})
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})
这篇关于如何加载HTML文件中木偶的.js +骨干?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文