您的位置:首页 > 产品设计 > UI/UE

backbone--requirejs--marionettejs--01

2015-07-25 20:21 417 查看
/** * tenant.index.js * @authors Caijw (573301753@qq.com) * @date 2015-07-22 16:52:00 * @version $Id$ */require.config({baseUrl : 'js',paths : {'jquery' : 'lib/jquery.min','underscore' : 'lib/underscore-min','backbone' : 'lib/backbone-min','mustache' : 'lib/mustache.min','backbone.marionette'
: 'lib/backbone.marionette.min','text': 'lib/text'},shim : {'underscore' : {exports : '_'},'mustache':{exports:"Mustache"},'backbone' : {deps : [ 'underscore', 'jquery' ],exports : 'Backbone'},'backbone.marionette' : {deps : [ 'backbone' ],exports : 'Marionette'}}});require(['jquery','underscore','backbone','mustache','backbone.marionette','text'],
function($,_,Backbone,Mustache,Marionette,T) {// alert(1);var ContactManager= new Marionette.Application();//区域ContactManager.addRegions({mainRegion:"#main-region"});//视图ContactManager.ContactView = Marionette.ItemView.extend({template:"#contact-template",events:{'click
p':'alertPhoneNumber'},alertPhoneNumber:function(){//显示模型的内容alert(this.model.get("phoneNumber"));// but escape will escape HTMLcontent,protecting youfrom XSS attacksif you’r edisplaying user-provided data within the HTML//escape更高级一点 避免xssalert(this.model.escape("phoneNumber"));}});//
模型,就是拿来存数据用的。ContactManager.Contact = Backbone.Model.extend({defaults:{firstName : "dd",}});//开始ContactManager.on("start",function(){//console.log("ContactManager has Started");// var staticView = new ContactManager.StaticView({// template:"#different-static-template",//
tagName:"span",// className:"blue",// id:"static-view",// });var alice = new ContactManager.Contact({lastName : "Arten",phoneNumber : "555-0184"});var aliceView = new ContactManager.ContactView({model:alice})ContactManager.mainRegion.show(aliceView);})ContactManager.start();//
这是因为marionette需要一个标签去让视图显示在Dom中,默认是div// 1 ContactManager.StaticView=Marionette.ItemView.extend({// 2 id:"static-view",// 3 tagName:"span",// 4 className:"instruction",// 5 template:"#static-template"// 6 });});

here is static content in the web page,you will notice that it getsreplaced by our app as soon as we start it
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: