学习内容:http://marionettejs.com/docs/master/basics.html
<script src="js/jquery.js"></script>
<script src="js/underscore.js"></script>
<script src="js/backbone.js"></script>
<script src="js/backbone.radio.js"></script>
<script src="js/backbone.marionette.js"></script>
这些都是必需的。
<section id="example">
<h3>Here is the example</h3>
<article id="article-region"></article>
</section>
<!--template-->
<template id="template-identifier">
<div>example</div>
</template>
.bg-success{background-color: green;}
.bg-error{background-color: red;}
//-model-
var MyModel= Backbone.Model.extend({});
var myModel= new MyModel();
myModel.set('isSuccessful',true);
//-子View-
var MyView=Mn.View.extend({
template: '#template-identifier',
className: function(){
return this.model.get('isSuccessful')? 'bg-success':'bg-error'
},
});
var myView=new MyView({model:myModel});
//-父View-
var ContainerView= Mn.View.extend({
template: false,
el: '#example',
regions: {
'myRegion':'#article-region'
}
});
var containerView= new ContainerView();
containerView.showChildView('myRegion',myView);